Files
kotlin-fork/compiler/testData/codegen/box/when/stringOptimization/nullability.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

50 lines
1.2 KiB
Kotlin
Vendored

// WITH_STDLIB
// CHECK_CASES_COUNT: function=foo1 count=2 TARGET_BACKENDS=JS
// CHECK_CASES_COUNT: function=foo1 count=5 IGNORED_BACKENDS=JS
// CHECK_IF_COUNT: function=foo1 count=1 TARGET_BACKENDS=JS
// CHECK_IF_COUNT: function=foo1 count=0 IGNORED_BACKENDS=JS
// CHECK_CASES_COUNT: function=foo2 count=4
// CHECK_IF_COUNT: function=foo2 count=0
import kotlin.test.assertEquals
fun foo1(x : String?) : String {
when (x) {
"abc", "cde" -> return "abc_cde"
"efg", "ghi", null -> return "efg_ghi"
}
return "other"
}
fun foo2(x : String?) : String {
when (x) {
"abc", "cde" -> return "abc_cde"
"efg", "ghi" -> return "efg_ghi"
else -> return "other"
}
}
fun box() : String {
//foo1
assertEquals("abc_cde", foo1("abc"))
assertEquals("abc_cde", foo1("cde"))
assertEquals("efg_ghi", foo1("efg"))
assertEquals("efg_ghi", foo1("ghi"))
assertEquals("efg_ghi", foo1(null))
assertEquals("other", foo1("xyz"))
//foo2
assertEquals("abc_cde", foo2("abc"))
assertEquals("abc_cde", foo2("cde"))
assertEquals("efg_ghi", foo2("efg"))
assertEquals("efg_ghi", foo2("ghi"))
assertEquals("other", foo2("xyz"))
assertEquals("other", foo2(null))
return "OK"
}