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

This commit is contained in:
Dmitry Petrov
2019-09-10 16:03:50 +03:00
parent f3837e91e3
commit cb13dd3cdd
5 changed files with 358 additions and 0 deletions
@@ -0,0 +1,61 @@
// !LANGUAGE: +AllowBreakAndContinueInsideWhen
fun testBreakFor() {
val xs = IntArray(10) { i -> i }
var k = 0
for (x in xs) {
when {
k > 2 -> break
}
}
}
fun testBreakWhile() {
var k = 0
while (k < 10) {
when {
k > 2 -> break
}
}
}
fun testBreakDoWhile() {
var k = 0
do {
when {
k > 2 -> break
}
} while (k < 10)
}
fun testContinueFor() {
val xs = IntArray(10) { i -> i }
var k = 0
for (x in xs) {
when {
k > 2 -> continue
}
}
}
fun testContinueWhile() {
var k = 0
while (k < 10) {
when {
k > 2 -> continue
}
}
}
fun testContinueDoWhile() {
var k = 0
var s = ""
do {
++k
when {
k > 2 -> continue
}
s += "$k;"
} while (k < 10)
if (s != "1;2;") throw AssertionError(s)
}