From 03f0c6ede75d85dec7b706368c8de3f06c542e05 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Tue, 17 Mar 2015 14:32:02 +0300 Subject: [PATCH] JS: added test for callable reference as stdlib inline function argument --- .../semantics/InlineJsStdlibTestGenerated.java | 6 ++++++ .../cases/callableRefToFunInCurrentModule.kt | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 js/js.translator/testData/inlineStdlib/cases/callableRefToFunInCurrentModule.kt diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineJsStdlibTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineJsStdlibTestGenerated.java index 52d1f8a762c..a321899a185 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineJsStdlibTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineJsStdlibTestGenerated.java @@ -42,6 +42,12 @@ public class InlineJsStdlibTestGenerated extends AbstractInlineJsStdlibTest { doTest(fileName); } + @TestMetadata("callableRefToFunInCurrentModule.kt") + public void testCallableRefToFunInCurrentModule() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/inlineStdlib/cases/callableRefToFunInCurrentModule.kt"); + doTest(fileName); + } + @TestMetadata("closure.kt") public void testClosure() throws Exception { String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/inlineStdlib/cases/closure.kt"); diff --git a/js/js.translator/testData/inlineStdlib/cases/callableRefToFunInCurrentModule.kt b/js/js.translator/testData/inlineStdlib/cases/callableRefToFunInCurrentModule.kt new file mode 100644 index 00000000000..c032ea49a52 --- /dev/null +++ b/js/js.translator/testData/inlineStdlib/cases/callableRefToFunInCurrentModule.kt @@ -0,0 +1,14 @@ +package foo + +// CHECK_NOT_CALLED_IN_SCOPE: scope=test function=even +// CHECK_NOT_CALLED_IN_SCOPE: scope=test function=filter_azvtw4$ + +fun even(x: Int) = x % 2 == 0 + +fun test(a: List) = a.filter(::even) + +fun box(): String { + assertEquals(listOf(2, 4), test(listOf(1, 2, 3, 4))) + + return "OK" +} \ No newline at end of file