Files
kotlin-fork/js/js.translator/testData/labels/cases/simpleLabel.kt
T
2014-10-27 15:58:49 +03:00

35 lines
531 B
Kotlin

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