BC native tests port to Konan's TestRunner

This commit is contained in:
Pavel Punegov
2017-10-11 15:09:33 +03:00
parent 9b07fd61ce
commit 9d077d7f4f
352 changed files with 1798 additions and 384 deletions
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.array_to_any
import kotlin.test.*
@Test
fun runTest() {
foo().hashCode()
}
@@ -1,3 +1,7 @@
package codegen.basics.canonical_name
import kotlin.test.*
interface I<U, T> {
fun foo(a: U): T
fun qux(a: T): U
@@ -24,10 +28,7 @@ fun <U, V> baz(i: I<U, V>, u: U, v:V) {
//-----------------------------------------------------------------------------//
fun main(args: Array<String>) {
@Test
fun runTest() {
baz<A1, A2>(A(), A1(), A2())
}
}
@@ -1,15 +1,20 @@
fun main(args: Array<String>) {
package codegen.basics.cast_null
import kotlin.test.*
@Test
fun runTest() {
testCast(null, false)
testCastToNullable(null, true)
testCastToNullable(Test(), true)
testCastToNullable(TestKlass(), true)
testCastToNullable("", false)
testCastNotNullableToNullable(Test(), true)
testCastNotNullableToNullable(TestKlass(), true)
testCastNotNullableToNullable("", false)
println("Ok")
}
class Test
class TestKlass
fun ensure(b: Boolean) {
if (!b) {
@@ -19,7 +24,7 @@ fun ensure(b: Boolean) {
fun testCast(x: Any?, expectSuccess: Boolean) {
try {
x as Test
x as TestKlass
} catch (e: Throwable) {
ensure(!expectSuccess)
return
@@ -29,7 +34,7 @@ fun testCast(x: Any?, expectSuccess: Boolean) {
fun testCastToNullable(x: Any?, expectSuccess: Boolean) {
try {
x as Test?
x as TestKlass?
} catch (e: Throwable) {
ensure(!expectSuccess)
return
@@ -39,7 +44,7 @@ fun testCastToNullable(x: Any?, expectSuccess: Boolean) {
fun testCastNotNullableToNullable(x: Any, expectSuccess: Boolean) {
try {
x as Test?
x as TestKlass?
} catch (e: Throwable) {
ensure(!expectSuccess)
return
@@ -1,3 +1,7 @@
package codegen.basics.cast_simple
import kotlin.test.*
open class A() {}
class B(): A() {}
@@ -9,6 +13,7 @@ fun castTest(): Boolean {
return true
}
fun main(args: Array<String>) {
@Test
fun runTest() {
if (!castTest()) throw Error()
}
@@ -1,3 +1,7 @@
package codegen.basics
import kotlin.test.*
interface I
class A() : I {}
class B() {}
@@ -28,8 +32,8 @@ fun isTypeOfInterface(a: Any) : Boolean {
//-----------------------------------------------------------------------------//
fun main(args: Array<String>) {
@Test
fun runTest() {
println(isTypeOf(A()))
println(isTypeOf(null))
println(isTypeNullableOf(A()))
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.concatenation
import kotlin.test.*
@Test
fun runTest() {
val s = "world"
val i = 1
println("Hello $s $i ${2*i}")
@@ -6,5 +11,4 @@ fun main(args: Array<String>) {
for (item in listOf("a", "b")) {
println("Hello, $item")
}
}
}
@@ -1,8 +1,13 @@
package codegen.basics.expression_as_statement
import kotlin.test.*
fun foo() {
Any() as String
}
fun main(args: Array<String>) {
@Test
fun runTest() {
try {
foo()
} catch (e: Throwable) {
@@ -1,9 +1,14 @@
package codegen.basics.local_variable
import kotlin.test.*
fun local_variable(a: Int) : Int {
var b = 0
b = a + 11
return b
}
fun main(args: Array<String>) {
@Test
fun runTest() {
if (local_variable(3) != 14) throw Error()
}
@@ -1,3 +1,7 @@
package codegen.basics.null_check
import kotlin.test.*
//--- Test "eqeq" -------------------------------------------------------------//
fun check_eqeq(a: Any?) = a == null
@@ -22,7 +26,8 @@ fun null_check_eqeqeq2() : Boolean {
return check_eqeqeq(null)
}
fun main(args: Array<String>) {
@Test
fun runTest() {
if (null_check_eqeq1()) throw Error()
if (!null_check_eqeq2()) throw Error()
if (null_check_eqeqeq1()) throw Error()
@@ -1,3 +1,7 @@
package codegen.basics.safe_cast
import kotlin.test.*
open class A
class B : A()
class C
@@ -14,8 +18,8 @@ fun safe_cast_negative(): Boolean {
return foo(c) == null
}
fun main(args: Array<String>) {
@Test
fun runTest() {
val safeCastPositive = safe_cast_positive().toString()
val safeCastNegative = safe_cast_negative().toString()
println("safe_cast_positive: " + safeCastPositive)
@@ -1,4 +1,9 @@
fun main(arg:Array<String>) {
package codegen.basics.spread_operator_0
import kotlin.test.*
@Test
fun runTest() {
val list0 = _arrayOf("K", "o", "t", "l", "i", "n")
val list1 = _arrayOf("l", "a","n", "g", "u", "a", "g", "e")
val list = foo(list0, list1)
@@ -1,3 +1,7 @@
package codegen.basics.superFunCall
import kotlin.test.*
open class C {
open fun f() = "<fun:C>"
}
@@ -13,7 +17,8 @@ class C3: C2() {
override fun f() = super<C2>.f() + "<fun:C3>"
}
fun main(args: Array<String>) {
@Test
fun runTest() {
println(C1().f())
println(C3().f())
}
@@ -1,3 +1,7 @@
package codegen.basics.superGetterCall
import kotlin.test.*
open class C {
open val p1 = "<prop:C>"
}
@@ -13,7 +17,8 @@ class C3: C2() {
override val p1 = super<C2>.p1 + "<prop:C3>"
}
fun main(args: Array<String>) {
@Test
fun runTest() {
println(C1().p1)
println(C3().p1)
}
@@ -1,3 +1,7 @@
package codegen.basics.superSetterCall
import kotlin.test.*
open class C {
open var p2 = "<prop:C>"
set(value) { field = "<prop:C>" + value }
@@ -22,7 +26,8 @@ class C3: C2() {
}
}
fun main(args: Array<String>) {
@Test
fun runTest() {
val c1 = C1()
val c3 = C3()
c1.p2 = "zzz"
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.typealias1
import kotlin.test.*
@Test
fun runTest() {
println(Bar(42).x)
}
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.unchecked_cast1
import kotlin.test.*
@Test
fun runTest() {
foo<String>("17")
bar<String>("17")
foo<String>(42)
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.unchecked_cast2
import kotlin.test.*
@Test
fun runTest() {
try {
val x = cast<String>(Any())
println(x.length)
@@ -1,12 +1,17 @@
fun main(args: Array<String>) {
testCast<Test>(Test(), true)
testCast<Test>(null, false)
testCastToNullable<Test>(null, true)
package codegen.basics.unchecked_cast3
import kotlin.test.*
@Test
fun runTest() {
testCast<TestKlass>(TestKlass(), true)
testCast<TestKlass>(null, false)
testCastToNullable<TestKlass>(null, true)
println("Ok")
}
class Test
class TestKlass
fun ensure(b: Boolean) {
if (!b) {
+6 -1
View File
@@ -1,3 +1,8 @@
fun main(args: Array<String>) {
package codegen.basics.unit1
import kotlin.test.*
@Test
fun runTest() {
println(println("First").toString())
}
+6 -1
View File
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.unit2
import kotlin.test.*
@Test
fun runTest() {
val x = foo()
println(x.toString())
}
+6 -1
View File
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.unit3
import kotlin.test.*
@Test
fun runTest() {
foo(Unit)
}
+6 -1
View File
@@ -1,4 +1,9 @@
fun main(args: Array<String>) {
package codegen.basics.unit4
import kotlin.test.*
@Test
fun runTest() {
for (x in 0 .. 8) {
foo(x, Unit)
}