Migrate boxInline tests to new multi-file framework

This commit is contained in:
Alexander Udalov
2016-02-24 13:29:32 +03:00
committed by Alexander Udalov
parent fa1f7d988e
commit cc84aabdcf
586 changed files with 6946 additions and 5639 deletions
@@ -0,0 +1,56 @@
// FILE: 1.kt
package test
class A
class B
inline fun <reified T> Any?.foo(): T? = this as? T
// FILE: 2.kt
import test.*
fun box(): String {
if (null.foo<Any>() != null) return "failTypeCast 1"
if (null.foo<Any?>() != null) return "failTypeCast 2"
if (null.foo<A>() != null) return "failTypeCast 3"
if (null.foo<A?>() != null) return "failTypeCast 4"
val a = A()
if (a.foo<Any>() != a) return "failTypeCast 5"
if (a.foo<Any?>() != a) return "failTypeCast 6"
if (a.foo<A>() != a) return "failTypeCast 7"
if (a.foo<A?>() != a) return "failTypeCast 8"
val b = B()
if (b.foo<A>() != null) return "fail 9"
if (b.foo<A?>() != null) return "fail 10"
return "OK"
}
inline fun failTypeCast(s: () -> Unit) {
try {
s()
}
catch (e: TypeCastException) {
}
}
inline fun failClassCast(s: () -> Unit) {
try {
s()
}
catch (e: TypeCastException) {
throw e
}
catch (e: ClassCastException) {
}
}