diff --git a/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java b/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java index 6f39d3ec7ba..b598bb09a00 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java @@ -42,6 +42,8 @@ import static org.jetbrains.k2js.test.utils.JsTestUtils.convertFileNameToDotJsFi * @author Pavel Talanov */ public abstract class BasicTest extends KotlinTestWithEnvironment { + // predictable order of ecma version in tests + protected static final Iterable DEFAULT_ECMA_VERSIONS = Lists.newArrayList(EcmaVersion.v5, EcmaVersion.v3); private static final boolean DELETE_OUT = false; private static final String TEST_FILES = "js/js.translator/testFiles/"; diff --git a/js/js.tests/test/org/jetbrains/k2js/test/MultipleFilesTranslationTest.java b/js/js.tests/test/org/jetbrains/k2js/test/MultipleFilesTranslationTest.java index 5287f640950..c49ce3e7af5 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/MultipleFilesTranslationTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/MultipleFilesTranslationTest.java @@ -21,7 +21,6 @@ import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.facade.MainCallParameters; import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker; -import java.util.EnumSet; import java.util.List; import static org.jetbrains.k2js.test.utils.JsTestUtils.getAllFilesInDir; @@ -35,17 +34,17 @@ public abstract class MultipleFilesTranslationTest extends BasicTest { super(main); } - protected void generateJsFromDir(@NotNull String dirName, @NotNull EnumSet ecmaVersions) throws Exception { + protected void generateJsFromDir(@NotNull String dirName, @NotNull Iterable ecmaVersions) throws Exception { List fullFilePaths = getAllFilesInDir(getInputFilePath(dirName)); generateJavaScriptFiles(fullFilePaths, dirName, MainCallParameters.noCall(), ecmaVersions); } protected void runMultiFileTest(@NotNull String dirName, @NotNull String namespaceName, @NotNull String functionName, @NotNull Object expectedResult) throws Exception { - runMultiFileTests(EcmaVersion.all(), dirName, namespaceName, functionName, expectedResult); + runMultiFileTests(DEFAULT_ECMA_VERSIONS, dirName, namespaceName, functionName, expectedResult); } - protected void runMultiFileTests(@NotNull EnumSet ecmaVersions, @NotNull String dirName, + protected void runMultiFileTests(@NotNull Iterable ecmaVersions, @NotNull String dirName, @NotNull String namespaceName, @NotNull String functionName, @NotNull Object expectedResult) diff --git a/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java b/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java index 37ff4778dda..f7610c30a8b 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java @@ -23,8 +23,6 @@ import org.jetbrains.k2js.facade.MainCallParameters; import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker; import org.jetbrains.k2js.test.rhino.RhinoSystemOutputChecker; -import java.util.EnumSet; - import static org.jetbrains.k2js.test.utils.JsTestUtils.readFile; /** @@ -32,14 +30,13 @@ import static org.jetbrains.k2js.test.utils.JsTestUtils.readFile; */ @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") public abstract class SingleFileTranslationTest extends BasicTest { - public SingleFileTranslationTest(@NotNull String main) { super(main); } public void runFunctionOutputTest(@NotNull String kotlinFilename, @NotNull String namespaceName, @NotNull String functionName, @NotNull Object expectedResult) throws Exception { - runFunctionOutputTest(EcmaVersion.all(), kotlinFilename, namespaceName, functionName, expectedResult); + runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, kotlinFilename, namespaceName, functionName, expectedResult); } protected void runFunctionOutputTest(@NotNull Iterable ecmaVersions, @NotNull String kotlinFilename, @@ -54,16 +51,20 @@ public abstract class SingleFileTranslationTest extends BasicTest { runFunctionOutputTest(ecmaVersions, filename, "foo", "box", true); } - public void checkFooBoxIsValue(@NotNull String filename, @NotNull EnumSet ecmaVersions, Object expected) throws Exception { + public void checkFooBoxIsTrue(@NotNull String filename) throws Exception { + runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, filename, "foo", "box", true); + } + + public void checkFooBoxIsValue(@NotNull String filename, @NotNull Iterable ecmaVersions, Object expected) throws Exception { runFunctionOutputTest(ecmaVersions, filename, "foo", "box", expected); } protected void fooBoxTest() throws Exception { - checkFooBoxIsTrue(getTestName(true) + ".kt", EcmaVersion.all()); + checkFooBoxIsTrue(getTestName(true) + ".kt", DEFAULT_ECMA_VERSIONS); } protected void fooBoxIsValue(Object expected) throws Exception { - checkFooBoxIsValue(getTestName(true) + ".kt", EcmaVersion.all(), expected); + checkFooBoxIsValue(getTestName(true) + ".kt", DEFAULT_ECMA_VERSIONS, expected); } protected void fooBoxTest(@NotNull Iterable ecmaVersions) throws Exception { @@ -71,17 +72,17 @@ public abstract class SingleFileTranslationTest extends BasicTest { } protected void checkFooBoxIsOk(@NotNull String filename) throws Exception { - checkFooBoxIsOk(EcmaVersion.all(), filename); + checkFooBoxIsOk(DEFAULT_ECMA_VERSIONS, filename); } - protected void checkFooBoxIsOk(@NotNull EnumSet versions, @NotNull String filename) throws Exception { + protected void checkFooBoxIsOk(@NotNull Iterable versions, @NotNull String filename) throws Exception { runFunctionOutputTest(versions, filename, "foo", "box", "OK"); } protected void checkOutput(@NotNull String kotlinFilename, @NotNull String expectedResult, @NotNull String... args) throws Exception { - checkOutput(kotlinFilename, expectedResult, EcmaVersion.all(), args); + checkOutput(kotlinFilename, expectedResult, DEFAULT_ECMA_VERSIONS, args); } protected void checkOutput(@NotNull String kotlinFilename, @@ -100,6 +101,6 @@ public abstract class SingleFileTranslationTest extends BasicTest { } protected void performTestWithMain(@NotNull String testName, @NotNull String testId, @NotNull String... args) throws Exception { - performTestWithMain(EcmaVersion.all(), testName, testId, args); + performTestWithMain(DEFAULT_ECMA_VERSIONS, testName, testId, args); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/CompileMavenGeneratedJSLibrary.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/CompileMavenGeneratedJSLibrary.java index b415c6319e7..7ee13c6c27f 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/CompileMavenGeneratedJSLibrary.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/CompileMavenGeneratedJSLibrary.java @@ -17,21 +17,16 @@ */ package org.jetbrains.k2js.test.semantics; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.ExitCode; import org.jetbrains.jet.cli.js.K2JSCompiler; import org.jetbrains.jet.cli.js.K2JSCompilerArguments; -import org.jetbrains.k2js.config.Config; import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.test.SingleFileTranslationTest; import java.io.File; -import java.util.EnumSet; import java.util.List; -import java.util.Set; /** * Lets test compiling all the JS code thats used by the library-js-library from the maven build @@ -59,7 +54,7 @@ public class CompileMavenGeneratedJSLibrary extends SingleFileTranslationTest { public void DISABLED_testGenerateTestCase() throws Exception { if (generatedJsLibraryDir.exists() && generatedJsLibraryDir.isDirectory()) { - generateJavaScriptFiles(EcmaVersion.all(), + generateJavaScriptFiles(DEFAULT_ECMA_VERSIONS, "libraries/stdlib/test", "ArraysTest.kt", "dom/DomTest.kt", @@ -77,7 +72,7 @@ public class CompileMavenGeneratedJSLibrary extends SingleFileTranslationTest { } } - protected void generateJavaScriptFiles(@NotNull EnumSet ecmaVersions, + protected void generateJavaScriptFiles(@NotNull Iterable ecmaVersions, @NotNull String sourceDir, @NotNull String... stdLibFiles) throws Exception { List files = Lists.newArrayList(); diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java index aac8760f744..26346b35192 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java @@ -18,7 +18,6 @@ package org.jetbrains.k2js.test.semantics; import junit.framework.Test; import org.jetbrains.annotations.NotNull; -import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.test.BasicTest; import org.jetbrains.k2js.test.SingleFileTranslationTest; @@ -39,7 +38,7 @@ public final class SimpleTest extends SingleFileTranslationTest { @Override public void runTest() throws Exception { - checkFooBoxIsTrue(filename, EcmaVersion.all()); + checkFooBoxIsTrue(filename, DEFAULT_ECMA_VERSIONS); } public static Test suite() throws Exception { diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTest.java index 703386efb8e..e2ef7c30fcb 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTest.java @@ -41,7 +41,7 @@ public final class StdLibTest extends SingleFileTranslationTest { } public void testBrowserDocumentAccessCompiles() throws Exception { - generateJavaScriptFiles("browserDocumentAccess.kt", MainCallParameters.noCall(), EcmaVersion.all()); + generateJavaScriptFiles("browserDocumentAccess.kt", MainCallParameters.noCall(), DEFAULT_ECMA_VERSIONS); } @Override diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java index dc74ddcfb3f..56ccd457a9b 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java @@ -16,13 +16,11 @@ package org.jetbrains.k2js.test.semantics; -import org.jetbrains.k2js.config.EcmaVersion; - /** */ public class StdLibTestToJSTest extends StdLibTestBase { public void testGenerateTestCase() throws Exception { - performStdLibTest(EcmaVersion.all(), + performStdLibTest(DEFAULT_ECMA_VERSIONS, "libraries/stdlib/test", "dom/DomTest.kt", "js/MapJsTest.kt", diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java index 51cf40a85e4..b07e63ae899 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java @@ -16,14 +16,12 @@ package org.jetbrains.k2js.test.semantics; -import org.jetbrains.k2js.config.EcmaVersion; - /** */ public class StdLibToJSTest extends StdLibTestBase { public void testCompileJavaScriptFiles() throws Exception { - performStdLibTest(EcmaVersion.all(), + performStdLibTest(DEFAULT_ECMA_VERSIONS, "libraries/stdlib/src"); } } diff --git a/js/js.translator/src/org/jetbrains/k2js/config/EcmaVersion.java b/js/js.translator/src/org/jetbrains/k2js/config/EcmaVersion.java index 9b64df99f47..29915961ee4 100644 --- a/js/js.translator/src/org/jetbrains/k2js/config/EcmaVersion.java +++ b/js/js.translator/src/org/jetbrains/k2js/config/EcmaVersion.java @@ -20,8 +20,6 @@ import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.EnumSet; - /** * @author Pavel Talanov */ @@ -37,9 +35,4 @@ public enum EcmaVersion { public static EcmaVersion defaultVersion() { return v3; } - - @NotNull - public static EnumSet all() { - return EnumSet.allOf(EcmaVersion.class); - } }