When by String constants:
Generate TABLESWITCH/LOOKUPSWITCH bytecode operation for when operator by String constants
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
5a1c995b5c
commit
d4cb822ee8
@@ -0,0 +1,20 @@
|
||||
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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user