Add more tests for constructor call evaluation order
- break in arguments - continue in arguments - early return in arguments - non-local return in arguments - nested constructor call in arguments
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
for (count in 0..3) {
|
||||
val test = Foo(count, Foo(1, "x", if (count > 0) break else 2), 3)
|
||||
if (count > 0) return "Fail: count = $count"
|
||||
if (test.toString() != "Foo(0,Foo(1,x,2),3)") return "Fail: ${test.toString()}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: util.kt
|
||||
val log = StringBuilder()
|
||||
|
||||
fun <T> logged(msg: String, value: T): T {
|
||||
log.append(msg)
|
||||
return value
|
||||
}
|
||||
|
||||
// FILE: Foo.kt
|
||||
class Foo(val a: Int, val b: Any, val c: Int) {
|
||||
init {
|
||||
log.append("<init>")
|
||||
}
|
||||
|
||||
override fun toString() = "Foo($a,$b,$c)"
|
||||
|
||||
companion object {
|
||||
init {
|
||||
log.append("<clinit>")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user