From 53abc956ccc283f2c8a066f5f8efed61693a5654 Mon Sep 17 00:00:00 2001 From: Erokhin Stanislav Date: Fri, 4 Oct 2013 15:11:40 +0400 Subject: [PATCH] JS backend: add simple test connected with frontend bug 'isStatement' for function body == 'hasBlockBody' --- .../jetbrains/k2js/test/semantics/FunctionTest.java | 4 ++++ .../expression/function/cases/whenFunction.kt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 js/js.translator/testFiles/expression/function/cases/whenFunction.kt diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/FunctionTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/FunctionTest.java index 32deb8ca0d9..d8aead859ab 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/FunctionTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/FunctionTest.java @@ -30,6 +30,10 @@ public class FunctionTest extends AbstractExpressionTest { fooBoxTest(); } + public void testWhenFunction() throws Exception { + checkFooBoxIsOk(); + } + public void testFunctionLiteral() throws Exception { fooBoxTest(); } diff --git a/js/js.translator/testFiles/expression/function/cases/whenFunction.kt b/js/js.translator/testFiles/expression/function/cases/whenFunction.kt new file mode 100644 index 00000000000..c00bce74a40 --- /dev/null +++ b/js/js.translator/testFiles/expression/function/cases/whenFunction.kt @@ -0,0 +1,11 @@ +package foo + +fun foo(a: Int): Int = when { + a == 1 || a + 2 == 3 -> 5 + else -> 6 +} +fun box(): String { + if (foo(1) != 5) return "fail1: ${foo(1)}" + if (foo(2) != 6) return "fail2: ${foo(1)}" + return "OK" +} \ No newline at end of file