TEST: test includes labeled continue-break
This commit is contained in:
committed by
KonstantinAnisimov
parent
bafa7e7c3c
commit
9afdfc316b
@@ -611,7 +611,7 @@ task unreachable1(type: RunKonanTest) {
|
||||
}
|
||||
|
||||
task break_continue(type: RunKonanTest) {
|
||||
goldValue = "while 2\nwhile 4\nwhile 6\nwhile 2\nwhile 4\nwhile 6\nwhile 1\nwhile 3\nwhile 5\n"
|
||||
goldValue = "foo@l1\nfoo@l2\nfoo@l2\nfoo@l2\nbar@l1\nbar@l2\nbar@l2\nbar@l2\nqux@t1\nqux@l2\nqux@l2\nqux@l2\n"
|
||||
source = "codegen/controlflow/break.kt"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,52 @@
|
||||
fun foo1() {
|
||||
fun foo() {
|
||||
var i = 0
|
||||
while (true) {
|
||||
if ((i++ % 2) == 0) continue
|
||||
println("while " + i.toString())
|
||||
if (i > 4) break
|
||||
l1@while (true) {
|
||||
println("foo@l1")
|
||||
try {
|
||||
l2@while (true) {
|
||||
if ((i++ % 2) == 0) continue@l2
|
||||
println("foo@l2")
|
||||
if (i > 4) break@l1
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo2() {
|
||||
fun bar() {
|
||||
var i = 0
|
||||
do {
|
||||
if ((i++ % 2) == 0) continue
|
||||
println("while " + i.toString())
|
||||
if (i > 4) break
|
||||
l1@do {
|
||||
try {
|
||||
println("bar@l1")
|
||||
throw Exception()
|
||||
} catch (e: Exception) {
|
||||
l2@do {
|
||||
if ((i++ % 2) == 0) continue@l2
|
||||
println("bar@l2")
|
||||
if (i > 4) break@l1
|
||||
} while (true)
|
||||
}
|
||||
} while (true)
|
||||
}
|
||||
|
||||
fun foo3() {
|
||||
for (i in 1..6) {
|
||||
if ((i % 2) == 0) continue
|
||||
println("while " + i.toString())
|
||||
if (i > 4) break
|
||||
fun qux() {
|
||||
l1@for (i in 1..6) {
|
||||
t1@try {
|
||||
println("qux@t1")
|
||||
throw Exception()
|
||||
}
|
||||
finally {
|
||||
l2@ for (j in 1..6) {
|
||||
if ((j % 2) == 0) continue@l2
|
||||
println("qux@l2")
|
||||
if (j > 4) break@l1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
foo()
|
||||
bar()
|
||||
qux()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user