Extract some codegen tests to black box testData
This commit is contained in:
committed by
Alexander Udalov
parent
f7e0b06c2f
commit
10c5949199
@@ -0,0 +1,8 @@
|
||||
fun foo(x: Any) = x as Runnable
|
||||
|
||||
fun box(): String {
|
||||
val r = object : Runnable {
|
||||
override fun run() {}
|
||||
}
|
||||
return if (foo(r) identityEquals r) "OK" else "Fail"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo(x: Any) = x as? Runnable
|
||||
|
||||
fun box(): String {
|
||||
val r = object : Runnable {
|
||||
override fun run() {}
|
||||
}
|
||||
return if (foo(r) identityEquals r) "OK" else "Fail"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo(x: Any) = x is Runnable
|
||||
|
||||
fun box(): String {
|
||||
val r = object : Runnable {
|
||||
override fun run() {}
|
||||
}
|
||||
return if (foo(r) && !foo(42)) "OK" else "Fail"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo(x: Any) = x !is Runnable
|
||||
|
||||
fun box(): String {
|
||||
val r = object : Runnable {
|
||||
override fun run() {}
|
||||
}
|
||||
return if (!foo(r) && foo(42)) "OK" else "Fail"
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
fun StringBuilder.first() = this.charAt(0)
|
||||
|
||||
fun foo() = StringBuilder("foo").first()
|
||||
|
||||
fun box() = if (foo() == 'f') "OK" else "Fail ${foo()}"
|
||||
+10
@@ -12,3 +12,13 @@ fun foo(expr: StringBuilder): Int {
|
||||
else -> throw Exception("nonzero" + c)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
foo(StringBuilder())
|
||||
return "Fail"
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user