Files
kotlin/compiler/testData/codegen/box/when/stringOptimization/sameHashCode.kt
2019-12-24 19:26:05 +03:00

29 lines
571 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
import kotlin.test.assertEquals
fun foo(x : String) : String {
assertEquals("abz]".hashCode(), "aby|".hashCode())
when (x) {
"abz]", "cde" -> return "abz_cde"
"aby|", "ghi", "abz]" -> return "aby_ghi"
}
return "other"
}
fun box() : String {
assertEquals("abz_cde", foo("abz]"))
assertEquals("abz_cde", foo("cde"))
assertEquals("aby_ghi", foo("aby|"))
assertEquals("aby_ghi", foo("ghi"))
assertEquals("other", foo("xyz"))
return "OK"
}