Files
Alexander Udalov c706673de9 Minor, refactor bytecode text tests on when-over-string optimization
- Merge `duplicatingItemsSameHashCode.kt` and
  `duplicatingItemsSameHashCode2.kt` into one test enabled on both
  backends, and rename it to
  `duplicatingItemsSameHashCodeFewBranches.kt`.
- Rename `duplicatingItemsSameHashCode3.kt` to
  `duplicatingItemsSameHashCodeMoreBranches.kt`, and also enable it for
  both backends.
- Use JVM_TEMPLATES/JVM_IR_TEMPLATES to check backend-specific behavior:
    1) JVM IR does not optimize less than 2 branches by design
    2) JVM IR does not generate duplicate branches, also by design

Related to KT-36846.
2020-08-31 16:47:11 +02:00

20 lines
430 B
Kotlin
Vendored

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"
}
// JVM_TEMPLATES:
// 1 LOOKUPSWITCH
// JVM_IR_TEMPLATES:
// Expecting 0 LOOKUPSWITCH as there is only 2 different hash codes. An IF cascade is more efficient.
// 0 LOOKUPSWITCH