BC native tests port to Konan's TestRunner
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user