diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/MiscTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/MiscTest.java index 7b0252593fb..a6a155da5df 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/MiscTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/MiscTest.java @@ -197,4 +197,8 @@ public final class MiscTest extends AbstractExpressionTest { public void testToGeneratorInStdlib() throws Exception { checkFooBoxIsOk(); } + + public void testThrowThrow() throws Exception { + checkFooBoxIsOk(); + } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/WhenTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/WhenTest.java index 5c1d72d47c1..8bdfa1127de 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/WhenTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/WhenTest.java @@ -141,4 +141,12 @@ public final class WhenTest extends AbstractExpressionTest { public void testWhenEqualsPattern() throws Exception { checkFooBoxIsOk(); } + + public void testWhenWithIfConditionAndOnlyElse() throws Exception { + checkFooBoxIsOk(); + } + + public void testWhenConditionWithReturn() throws Exception { + checkFooBoxIsOk(); + } } diff --git a/js/js.translator/testData/expression/misc/cases/throwThrow.kt b/js/js.translator/testData/expression/misc/cases/throwThrow.kt new file mode 100644 index 00000000000..d6cd68db71b --- /dev/null +++ b/js/js.translator/testData/expression/misc/cases/throwThrow.kt @@ -0,0 +1,16 @@ +package foo + +fun test() { + throw throw Exception("catch me") +} + +fun box(): String { + try { + test() + error("exception not thrown") + } + catch (e: Exception) { + assertEquals("catch me", e.message) + } + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/expression/when/cases/whenConditionWithReturn.kt b/js/js.translator/testData/expression/when/cases/whenConditionWithReturn.kt new file mode 100644 index 00000000000..2d1864778d4 --- /dev/null +++ b/js/js.translator/testData/expression/when/cases/whenConditionWithReturn.kt @@ -0,0 +1,13 @@ +package foo + +fun test(): Int { + return when { + (return 23) is Int -> 24 + else -> 25 + } +} + +fun box(): String { + assertEquals(23, test()) + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/expression/when/cases/whenWithIfConditionAndOnlyElse.kt b/js/js.translator/testData/expression/when/cases/whenWithIfConditionAndOnlyElse.kt new file mode 100644 index 00000000000..df3d8cc8678 --- /dev/null +++ b/js/js.translator/testData/expression/when/cases/whenWithIfConditionAndOnlyElse.kt @@ -0,0 +1,15 @@ +package foo + +var global = "" + +fun bar(a: T, i: Int): T { + global += "$i" + return a +} + +fun box(): String { + val x = 3 + when(if (x == 4) return bar("fail1", 1) else 4) { + else -> return bar("OK", 2) + } +} \ No newline at end of file