Files
kotlin-fork/js/js.translator/testData/box/labels/simpleLabelInlined.kt
T
2018-09-12 09:49:25 +03:00

45 lines
762 B
Kotlin
Vendored

// EXPECTED_REACHABLE_NODES: 1280
package foo
// CHECK_NOT_CALLED: testBreak
// CHECK_NOT_CALLED: testContinue
// CHECK_LABELS_COUNT: function=testBreakNoinline name=loop count=1
// CHECK_LABELS_COUNT: function=testContinueNoinline name=loop count=1
inline fun testBreak(): Int {
var i = 0
loop@ for (j in 1..10) {
if (j == 5) break@loop
i = j
}
return i
}
fun testBreakNoinline() {
assertEquals(4, testBreak(), "break")
}
inline fun testContinue(): Int {
var sum = 0
loop@ for (j in 1..5) {
if (j % 2 != 0) continue@loop
sum += j
}
return sum
}
fun testContinueNoinline() {
assertEquals(6, testContinue(), "continue")
}
fun box(): String {
testContinue()
return "OK"
}