Files
kotlin/compiler/testData/codegen/box/when/whenSubjectVariable/sparseIntSwitchWithSubjectVariable.kt
2018-08-09 14:22:50 +03:00

20 lines
398 B
Kotlin
Vendored

// !LANGUAGE: +VariableDeclarationInWhenSubject
// WITH_RUNTIME
// IGNORE_BACKEND: JS, JS_IR
fun sparse(x: Int): Int {
return when (val xx = (x % 4) * 100) {
100 -> 1
200 -> xx / 100
300 -> 3
else -> 4
}
}
fun box(): String {
var result = (0..3).map(::sparse).joinToString()
if (result != "4, 1, 2, 3") return "sparse:" + result
return "OK"
}