Add JS IR tests
diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt
index 4b10ee2..f189876 100644
--- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt
+++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt
@@ -33,6 +33,10 @@
model("box/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
}
+ testClass<AbstractIrBoxJsTest> {
+ model("irbox/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
+ }
+
testClass<AbstractSourceMapGenerationSmokeTest> {
model("sourcemap/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
}
diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt
index 5c87a06..30da05f 100644
--- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt
+++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt
@@ -82,7 +82,8 @@
testGroupOutputDirPrefix: String,
pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH,
private val generateSourceMap: Boolean = false,
- private val generateNodeJsRunner: Boolean = true
+ private val generateNodeJsRunner: Boolean = true,
+ private val ir: Boolean = false
) : KotlinTestWithEnvironment() {
val additionalCommonFileDirectories = mutableListOf<String>()
@@ -559,6 +560,8 @@
configuration.put(JSConfigurationKeys.SOURCE_MAP_SOURCE_ROOTS, sourceDirs)
configuration.put(JSConfigurationKeys.SOURCE_MAP_EMBED_SOURCES, module.sourceMapSourceEmbedding)
+ configuration.put(JSConfigurationKeys.IR_USED, ir)
+
return JsConfig(project, configuration, METADATA_CACHE, (JsConfig.JS_STDLIB + JsConfig.JS_KOTLIN_TEST).toSet())
}
diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java
new file mode 100644
index 0000000..692c193
--- /dev/null
+++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2010-2017 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.js.test.semantics;
+
+import com.intellij.testFramework.TestDataPath;
+import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
+import org.jetbrains.kotlin.test.KotlinTestUtils;
+import org.jetbrains.kotlin.test.TargetBackend;
+import org.jetbrains.kotlin.test.TestMetadata;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.util.regex.Pattern;
+
+/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
+@SuppressWarnings("all")
+@TestMetadata("js/js.translator/testData/irbox")
+@TestDataPath("$PROJECT_ROOT")
+@RunWith(JUnit3RunnerWithInners.class)
+public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
+ public void testAllFilesPresentInIrbox() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/irbox"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
+ }
+
+ @TestMetadata("js/js.translator/testData/irbox/simple")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class Simple extends AbstractIrBoxJsTest {
+ public void testAllFilesPresentInSimple() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/irbox/simple"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
+ }
+
+ @TestMetadata("invocation.kt")
+ public void testInvocation() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/irbox/simple/invocation.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("package.kt")
+ public void testPackage() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/irbox/simple/package.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("simple.kt")
+ public void testSimple() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/irbox/simple/simple.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("variable.kt")
+ public void testVariable() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/irbox/simple/variable.kt");
+ doTest(fileName);
+ }
+ }
+}
diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt
index 5812b96..ac1114e 100644
--- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt
+++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt
@@ -56,4 +56,10 @@
"sourcemap/",
generateSourceMap = true,
generateNodeJsRunner = false
+)
+
+abstract class AbstractIrBoxJsTest : BasicBoxTest(
+ BasicBoxTest.TEST_DATA_DIR_PATH + "irbox/",
+ BasicBoxTest.TEST_DATA_DIR_PATH + "out/irbox/",
+ ir = true
)
\ No newline at end of file
diff --git a/js/js.translator/testData/irbox/simple/invocation.kt b/js/js.translator/testData/irbox/simple/invocation.kt
new file mode 100644
index 0000000..69cd5da
--- /dev/null
+++ b/js/js.translator/testData/irbox/simple/invocation.kt
@@ -0,0 +1,7 @@
+fun box(): String {
+ return foo()
+}
+
+fun foo(): String {
+ return "OK"
+}
\ No newline at end of file
diff --git a/js/js.translator/testData/irbox/simple/package.kt b/js/js.translator/testData/irbox/simple/package.kt
new file mode 100644
index 0000000..6871f1c
--- /dev/null
+++ b/js/js.translator/testData/irbox/simple/package.kt
@@ -0,0 +1,5 @@
+package foo.bar
+
+fun box(): String {
+ return "OK"
+}
\ No newline at end of file
diff --git a/js/js.translator/testData/irbox/simple/simple.kt b/js/js.translator/testData/irbox/simple/simple.kt
new file mode 100644
index 0000000..a04c9c0
--- /dev/null
+++ b/js/js.translator/testData/irbox/simple/simple.kt
@@ -0,0 +1,3 @@
+fun box(): String {
+ return "OK"
+}
\ No newline at end of file
diff --git a/js/js.translator/testData/irbox/simple/variable.kt b/js/js.translator/testData/irbox/simple/variable.kt
new file mode 100644
index 0000000..8b6474b
--- /dev/null
+++ b/js/js.translator/testData/irbox/simple/variable.kt
@@ -0,0 +1,4 @@
+fun box(): String {
+ val ok = "OK"
+ return ok
+}
\ No newline at end of file