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