From 03e94c6877784f86f4398eb763e5a7da161b8fa9 Mon Sep 17 00:00:00 2001 From: Konstantin Anisimov Date: Thu, 1 Dec 2016 17:45:47 +0300 Subject: [PATCH] TEST: tests for "break" and "continue" added --- backend.native/tests/build.gradle | 5 +++ .../tests/codegen/controlflow/break.kt | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 backend.native/tests/codegen/controlflow/break.kt 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() +}