Add BE tests for 'break' and 'continue' inside 'when'

This commit is contained in:
Dmitry Petrov
2019-09-10 15:56:23 +03:00
parent f06f6f4660
commit f3837e91e3
7 changed files with 142 additions and 0 deletions
@@ -0,0 +1,49 @@
// !LANGUAGE: +AllowBreakAndContinueInsideWhen
fun testFor() {
val xs = IntArray(10) { i -> i }
var k = 0
var s = ""
for (x in xs) {
++k
when {
k > 2 -> continue
}
s += "$k;"
}
if (s != "1;2;") throw AssertionError(s)
}
fun testWhile() {
var k = 0
var s = ""
while (k < 10) {
++k
when {
k > 2 -> continue
}
s += "$k;"
}
if (s != "1;2;") throw AssertionError(s)
}
fun testDoWhile() {
var k = 0
var s = ""
do {
++k
when {
k > 2 -> continue
}
s += "$k;"
} while (k < 10)
if (s != "1;2;") throw AssertionError(s)
}
fun box(): String {
testFor()
testWhile()
testDoWhile()
return "OK"
}