mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 15:53:46 +00:00
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,24 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun foo(x : String) : String {
|
||||
assert("abz]".hashCode() == "aby|".hashCode())
|
||||
|
||||
when (x) {
|
||||
"abz]" -> return "abz"
|
||||
"ghi" -> return "ghi"
|
||||
"aby|" -> return "aby"
|
||||
"abz]" -> return "fail"
|
||||
}
|
||||
|
||||
return "other"
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
assertEquals("abz", foo("abz]"))
|
||||
assertEquals("aby", foo("aby|"))
|
||||
assertEquals("ghi", foo("ghi"))
|
||||
|
||||
assertEquals("other", foo("xyz"))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user