diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 1adc5d78071..fd74843a193 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -610,6 +610,11 @@ task unreachable1(type: RunKonanTest) { source = "codegen/controlflow/unreachable1.kt" } +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" + source = "codegen/controlflow/break.kt" +} + task range0(type: RunKonanTest) { goldValue = "123\nabcd\n" source = "runtime/collections/range0.kt" diff --git a/backend.native/tests/codegen/controlflow/break.kt b/backend.native/tests/codegen/controlflow/break.kt new file mode 100644 index 00000000000..12208de5e1a --- /dev/null +++ b/backend.native/tests/codegen/controlflow/break.kt @@ -0,0 +1,31 @@ +fun foo1() { + var i = 0 + while (true) { + if ((i++ % 2) == 0) continue + println("while " + i.toString()) + if (i > 4) break + } +} + +fun foo2() { + var i = 0 + do { + if ((i++ % 2) == 0) continue + println("while " + i.toString()) + if (i > 4) break + } while (true) +} + +fun foo3() { + for (i in 1..6) { + if ((i % 2) == 0) continue + println("while " + i.toString()) + if (i > 4) break + } +} + +fun main(args: Array) { + foo1() + foo2() + foo3() +}