Files
kotlin/compiler/testData/codegen/boxWithStdlib/whenStringOptimization/duplicatingItems.kt
Denis Zharkov d4cb822ee8 When by String constants:
Generate TABLESWITCH/LOOKUPSWITCH bytecode operation for when operator by String constants
2014-07-21 17:13:56 +04:00

21 lines
393 B
Kotlin
Vendored

import kotlin.test.assertEquals
fun foo(x : String) : String {
when (x) {
"abc" -> return "abc"
"efg", "ghi", "abc" -> return "efg_ghi"
else -> return "other"
}
}
fun box() : String {
assertEquals("abc", foo("abc"))
assertEquals("efg_ghi", foo("efg"))
assertEquals("efg_ghi", foo("ghi"))
assertEquals("other", foo("xyz"))
return "OK"
}