Files
kotlin-fork/compiler/testData/codegen/boxInline/complexStack/breakContinueInInlineLambdaArgument.kt
T
Ilmir Usmanov d6d331de2a Minor. Fix test
2020-05-08 19:36:02 +02:00

30 lines
658 B
Kotlin
Vendored

// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// FILE: 1.kt
inline fun List<String?>.forEachNotNull(s: String, fn: (String, String) -> Unit) {
for (x in this) {
fn(s, x ?: continue)
}
}
inline fun List<String?>.forEachUntilNull(s: String, fn: (String, String) -> Unit) {
for (x in this) {
fn(s, x ?: break)
}
}
// FILE: 2.kt
fun box(): String {
var res = ""
listOf("O", null, "K").forEachNotNull("|") { a, b ->
res += a + b
}
if (res != "|O|K") return res
res = ""
listOf("O", null, "K").forEachUntilNull("|") { a, b ->
res += a + b
}
if (res != "|O") return res
return "OK"
}