JS backend: added tests for labels

This commit is contained in:
Alexey Tsvetkov
2014-10-13 20:43:58 +04:00
parent 0bc05135d8
commit 09c98226c8
12 changed files with 378 additions and 4 deletions
@@ -0,0 +1,35 @@
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"
}