Migrate boxInline tests to new multi-file framework
This commit is contained in:
committed by
Alexander Udalov
parent
fa1f7d988e
commit
cc84aabdcf
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface Z {
|
||||
fun a() : String
|
||||
}
|
||||
|
||||
inline fun test(crossinline z: () -> String) =
|
||||
object : Z {
|
||||
|
||||
val p = z()
|
||||
|
||||
override fun a() = p
|
||||
}
|
||||
|
||||
|
||||
inline fun<T> call(crossinline z: () -> T) = z()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
/*This captured parameter would be added to object constructor*/
|
||||
val captured = "OK";
|
||||
var z: Any = "fail"
|
||||
val res = test {
|
||||
|
||||
call {
|
||||
z = {
|
||||
captured
|
||||
}
|
||||
}
|
||||
|
||||
(z as Function0<String>)()
|
||||
}
|
||||
|
||||
|
||||
val enclosingConstructor = z.javaClass.enclosingConstructor
|
||||
if (enclosingConstructor?.name != "TransformedConstructorWithNestedInline_1Kt\$box$\$inlined\$test$1") return "fail 1: ${enclosingConstructor?.name}"
|
||||
|
||||
val enclosingClass = z.javaClass.enclosingClass
|
||||
if (enclosingClass?.name != "TransformedConstructorWithNestedInline_1Kt\$box$\$inlined\$test$1") return "fail 2: ${enclosingClass?.name}"
|
||||
|
||||
return res.a()
|
||||
}
|
||||
Reference in New Issue
Block a user