From ed0d5a8b060d4839c0034b6f8549086f64a574f3 Mon Sep 17 00:00:00 2001 From: Pavel Talanov Date: Mon, 30 Jan 2012 20:31:19 +0400 Subject: [PATCH] added test for complex expression with when --- .idea/workspace.xml | 333 +++++++++++------- .../k2js/test/PatternMatchingTest.java | 5 + .../patternMatching/cases/whenWithIf.kt | 19 + 3 files changed, 222 insertions(+), 135 deletions(-) create mode 100644 translator/testFiles/patternMatching/cases/whenWithIf.kt diff --git a/.idea/workspace.xml b/.idea/workspace.xml index da4258d6769..3050b4b6845 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -13,12 +13,9 @@ - + - - - - + @@ -118,7 +115,7 @@ - + @@ -191,7 +188,7 @@ - + @@ -201,37 +198,46 @@ - - + + - + - - + + - + - - + + - + - - + + - + + + + + + + + + + @@ -240,52 +246,43 @@ - + - - + + - + - - + + - + - - + + - + - - + + - - - - - - - - - - + @@ -316,8 +313,6 @@ @@ -564,6 +561,74 @@ - - - - - - - - - - - - - - + @@ -763,6 +800,34 @@ + + + + + + + + + + + + + @@ -1136,20 +1201,6 @@ - - - - - - - - - - - - - - @@ -1157,51 +1208,30 @@ - - - - - - - - - - - - - - - + - + - + - + - + - + - - - - - - - - + @@ -1213,12 +1243,17 @@ - + - - - - + + + + + + + + + @@ -1229,13 +1264,6 @@ - - - - - - - @@ -1243,9 +1271,44 @@ + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/translator/test/org/jetbrains/k2js/test/PatternMatchingTest.java b/translator/test/org/jetbrains/k2js/test/PatternMatchingTest.java index 64d3dfba607..0d208559776 100644 --- a/translator/test/org/jetbrains/k2js/test/PatternMatchingTest.java +++ b/translator/test/org/jetbrains/k2js/test/PatternMatchingTest.java @@ -45,6 +45,11 @@ public final class PatternMatchingTest extends TranslationTest { // testFooBoxIsTrue("whenValueOrType.kt"); // } + @Test + public void whenWithIf() throws Exception { + testFooBoxIsTrue("whenWithIf.kt"); + } + @Test public void multipleCases() throws Exception { testFunctionOutput("multipleCases.kt", "foo", "box", 2.0); diff --git a/translator/testFiles/patternMatching/cases/whenWithIf.kt b/translator/testFiles/patternMatching/cases/whenWithIf.kt new file mode 100644 index 00000000000..f7df3292b4c --- /dev/null +++ b/translator/testFiles/patternMatching/cases/whenWithIf.kt @@ -0,0 +1,19 @@ +package foo + +fun box() : Boolean { + + var c = when(3) { + 3 -> 1 + 2 -> 100 + else -> 100 + } + when (2) { + 1 -> 100 + else -> 1 + } + when (0) { + 1 -> if (true) 100 else 100 + 0 -> if (false) {100} else {1} + else -> 100 + } + + return c == 3 +} \ No newline at end of file