JS backend: added tests for labels
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user