From 9afdfc316b245b0d4851de808d7f4e4b0174499a Mon Sep 17 00:00:00 2001 From: Konstantin Anisimov Date: Fri, 2 Dec 2016 15:55:02 +0300 Subject: [PATCH] TEST: test includes labeled continue-break --- backend.native/tests/build.gradle | 2 +- .../tests/codegen/controlflow/break.kt | 57 +++++++++++++------ 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index fd74843a193..93c364db3bd 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -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" } diff --git a/backend.native/tests/codegen/controlflow/break.kt b/backend.native/tests/codegen/controlflow/break.kt index 12208de5e1a..8564f03f0cd 100644 --- a/backend.native/tests/codegen/controlflow/break.kt +++ b/backend.native/tests/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) { - foo1() - foo2() - foo3() + foo() + bar() + qux() }