Files
kotlin-fork/compiler/testData/ir/loweredIr/interpreter/ifConstVal.kt
T
Ivan Kylchik 0b22cf6cb9 Rewrite ir interpreter's dump tests to box
Box tests will check the correctness of interpreter, meantime
by dumped ir we can understand that expression was folded.
2022-05-18 21:20:01 +03:00

27 lines
670 B
Kotlin
Vendored

const val flag = true
const val value = 10
const val condition = if (flag) "True" else "Error"
const val withWhen = when (flag) {
true -> "True"
else -> "Error"
}
const val withWhen2 = when {
flag == true -> "True"
else -> "Error"
}
const val withWhen3 = when(value) {
10 -> "1"
100 -> "2"
else -> "3"
}
const val multibranchIf = if (value == 100) 1 else if (value == 1000) 2 else 3
fun box(): String {
if (condition != "True") return "Fail 1"
if (withWhen != "True") return "Fail 2"
if (withWhen2 != "True") return "Fail 3"
if (withWhen3 != "1") return "Fail 4"
if (multibranchIf != 3) return "Fail 5"
return "OK"
}