From 6d414ba2221f4d6067557bda22ec3df3258d902e Mon Sep 17 00:00:00 2001 From: pTalanov Date: Tue, 15 May 2012 20:25:44 +0400 Subject: [PATCH] Mark the tests which are failing with EcmaVersion.v5 and exclude them --- .../test/MultipleFilesTranslationTest.java | 17 +++++-- .../k2js/test/SingleFileTranslationTest.java | 49 +++++++++++++++---- .../k2js/test/semantics/ExamplesTest.java | 23 +++++---- .../test/semantics/ExtensionPropertyTest.java | 8 +-- .../k2js/test/semantics/MiscTest.java | 27 +++++----- .../k2js/test/semantics/NamespaceTest.java | 9 ++-- .../test/semantics/NativeInteropTest.java | 3 +- .../semantics/OperatorOverloadingTest.java | 4 +- .../test/semantics/PropertyAccessTest.java | 9 ++-- .../k2js/test/semantics/RangeTest.java | 6 ++- .../k2js/test/semantics/SimpleTest.java | 22 +++++---- .../test/semantics/StandardClassesTest.java | 14 +++--- .../test/semantics/WebDemoExamples2Test.java | 8 +-- .../k2js/test/utils/JsTestUtils.java | 18 +++++++ 14 files changed, 148 insertions(+), 69 deletions(-) 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 172c29cd5b7..81c8b7225e8 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/MultipleFilesTranslationTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/MultipleFilesTranslationTest.java @@ -21,6 +21,7 @@ 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; @@ -34,15 +35,23 @@ public abstract class MultipleFilesTranslationTest extends BasicTest { super(main); } - protected void generateJsFromDir(@NotNull String dirName) throws Exception { + protected void generateJsFromDir(@NotNull String dirName, @NotNull EnumSet ecmaVersions) throws Exception { List fullFilePaths = getAllFilesInDir(getInputFilePath(dirName)); - generateJavaScriptFiles(fullFilePaths, dirName, MainCallParameters.noCall(), EcmaVersion.all()); + generateJavaScriptFiles(fullFilePaths, dirName, MainCallParameters.noCall(), ecmaVersions); } protected void runMultiFileTest(@NotNull String dirName, @NotNull String namespaceName, @NotNull String functionName, @NotNull Object expectedResult) throws Exception { - generateJsFromDir(dirName); - runRhinoTests(getOutputFilePaths(dirName + ".kt", EcmaVersion.all()), + runMultiFileTests(EcmaVersion.all(), dirName, namespaceName, functionName, expectedResult); + } + + protected void runMultiFileTests(@NotNull EnumSet ecmaVersions, @NotNull String dirName, + @NotNull String namespaceName, + @NotNull String functionName, + @NotNull Object expectedResult) + throws Exception { + generateJsFromDir(dirName, ecmaVersions); + runRhinoTests(getOutputFilePaths(dirName + ".kt", ecmaVersions), new RhinoFunctionResultChecker(namespaceName, functionName, 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 9af0b7034ce..da0572c0ec3 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java @@ -39,31 +39,60 @@ public abstract class SingleFileTranslationTest extends BasicTest { public void runFunctionOutputTest(@NotNull String kotlinFilename, @NotNull String namespaceName, @NotNull String functionName, @NotNull Object expectedResult) throws Exception { - EnumSet ecmaVersions = EcmaVersion.all(); + runFunctionOutputTest(EcmaVersion.all(), kotlinFilename, namespaceName, functionName, expectedResult); + } + + protected void runFunctionOutputTest(@NotNull EnumSet ecmaVersions, @NotNull String kotlinFilename, + @NotNull String namespaceName, + @NotNull String functionName, + @NotNull Object expectedResult) throws Exception { generateJavaScriptFiles(kotlinFilename, MainCallParameters.noCall(), ecmaVersions); runRhinoTests(getOutputFilePaths(kotlinFilename, ecmaVersions), new RhinoFunctionResultChecker(namespaceName, functionName, expectedResult)); } - public void checkFooBoxIsTrue(@NotNull String filename) throws Exception { - runFunctionOutputTest(filename, "foo", "box", true); + public void checkFooBoxIsTrue(@NotNull String filename, @NotNull EnumSet ecmaVersions) throws Exception { + runFunctionOutputTest(ecmaVersions, filename, "foo", "box", true); } - public void fooBoxTest() throws Exception { - checkFooBoxIsTrue(getTestName(true) + ".kt"); + protected void fooBoxTest() throws Exception { + checkFooBoxIsTrue(getTestName(true) + ".kt", EcmaVersion.all()); } - public void checkFooBoxIsOk(@NotNull String filename) throws Exception { - runFunctionOutputTest(filename, "foo", "box", "OK"); + protected void fooBoxTest(@NotNull EnumSet ecmaVersions) throws Exception { + checkFooBoxIsTrue(getTestName(true) + ".kt", ecmaVersions); } - protected void checkOutput(@NotNull String kotlinFilename, @NotNull String expectedResult, @NotNull String... args) throws Exception { - EnumSet ecmaVersions = EcmaVersion.all(); + protected void checkFooBoxIsOk(@NotNull String filename) throws Exception { + checkFooBoxIsOk(EcmaVersion.all(), filename); + } + + protected void checkFooBoxIsOk(@NotNull EnumSet 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); + } + + protected void checkOutput(@NotNull String kotlinFilename, + @NotNull String expectedResult, + @NotNull EnumSet ecmaVersions, + String... args) throws Exception { generateJavaScriptFiles(kotlinFilename, MainCallParameters.mainWithArguments(Lists.newArrayList(args)), ecmaVersions); runRhinoTests(getOutputFilePaths(kotlinFilename, ecmaVersions), new RhinoSystemOutputChecker(expectedResult)); } + protected void performTestWithMain(@NotNull EnumSet ecmaVersions, + @NotNull String testName, + @NotNull String testId, + @NotNull String... args) throws Exception { + checkOutput(testName + ".kt", readFile(expected(testName + testId)), ecmaVersions, args); + } + protected void performTestWithMain(@NotNull String testName, @NotNull String testId, @NotNull String... args) throws Exception { - checkOutput(testName + ".kt", readFile(expected(testName + testId)), args); + performTestWithMain(EcmaVersion.all(), testName, testId, args); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java index 944ccc6f766..de4d049dd61 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java @@ -22,6 +22,8 @@ import org.jetbrains.k2js.test.BasicTest; import org.jetbrains.k2js.test.SingleFileTranslationTest; import org.jetbrains.k2js.translate.context.Namer; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + @SuppressWarnings("JUnitTestCaseWithNoTests") public final class ExamplesTest extends SingleFileTranslationTest { @@ -36,18 +38,19 @@ public final class ExamplesTest extends SingleFileTranslationTest { @Override public void runTest() throws Exception { - runFunctionOutputTest(filename, Namer.getRootNamespaceName(), "box", "OK"); + runFunctionOutputTest(failsOnEcmaV5(), filename, Namer.getRootNamespaceName(), "box", "OK"); } public static Test suite() throws Exception { - return TranslatorTestCaseBuilder.suiteForDirectory(BasicTest.pathToTestFilesRoot() + "examples/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() { - @NotNull - @Override - public Test createTest(@NotNull String filename) { - ExamplesTest examplesTest = new ExamplesTest(filename); - examplesTest.setName(filename); - return examplesTest; - } - }); + return TranslatorTestCaseBuilder + .suiteForDirectory(BasicTest.pathToTestFilesRoot() + "examples/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() { + @NotNull + @Override + public Test createTest(@NotNull String filename) { + ExamplesTest examplesTest = new ExamplesTest(filename); + examplesTest.setName(filename); + return examplesTest; + } + }); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExtensionPropertyTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExtensionPropertyTest.java index 29588d3eea5..eb8ebb19e16 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExtensionPropertyTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExtensionPropertyTest.java @@ -18,6 +18,8 @@ package org.jetbrains.k2js.test.semantics; import org.jetbrains.k2js.test.SingleFileTranslationTest; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov */ @@ -28,14 +30,14 @@ public final class ExtensionPropertyTest extends SingleFileTranslationTest { } public void testSimplePropertyWithGetter() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testPropertyWithGetterAndSetter() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testAbsExtension() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java index 1fa25a13f89..3c13428bd20 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java @@ -16,9 +16,12 @@ package org.jetbrains.k2js.test.semantics; +import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.translate.context.Namer; import org.mozilla.javascript.JavaScriptException; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov *

@@ -36,7 +39,7 @@ public final class MiscTest extends AbstractExpressionTest { } public void testIntRange() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } @@ -45,7 +48,7 @@ public final class MiscTest extends AbstractExpressionTest { } public void testClassWithoutNamespace() throws Exception { - runFunctionOutputTest("classWithoutNamespace.kt", Namer.getRootNamespaceName(), "box", true); + runFunctionOutputTest(failsOnEcmaV5(), "classWithoutNamespace.kt", Namer.getRootNamespaceName(), "box", true); } public void testIfElseAsExpressionWithThrow() throws Exception { @@ -58,7 +61,7 @@ public final class MiscTest extends AbstractExpressionTest { } public void testKt1052_2() throws Exception { - checkFooBoxIsTrue("KT-1052-2.kt"); + checkFooBoxIsTrue("KT-1052-2.kt", EcmaVersion.all()); } public void testKt1052() throws Exception { @@ -67,27 +70,27 @@ public final class MiscTest extends AbstractExpressionTest { public void testKt740_1() throws Exception { - checkFooBoxIsTrue("KT-740.kt"); + checkFooBoxIsTrue("KT-740.kt", EcmaVersion.all()); } public void testKt740_2() throws Exception { - checkFooBoxIsOk("KT-740-2.kt"); + checkFooBoxIsOk(failsOnEcmaV5(), "KT-740-2.kt"); } public void testKt1361_1() throws Exception { - checkFooBoxIsTrue("KT-1361-1.kt"); + checkFooBoxIsTrue("KT-1361-1.kt", EcmaVersion.all()); } public void testKt1361_2() throws Exception { - checkFooBoxIsTrue("KT-1361-2.kt"); + checkFooBoxIsTrue("KT-1361-2.kt", EcmaVersion.all()); } public void testKt817() throws Exception { - checkFooBoxIsTrue("KT-817.kt"); + checkFooBoxIsTrue("KT-817.kt", EcmaVersion.all()); } public void testKt740_3() throws Exception { - checkFooBoxIsOk("KT-740-3.kt"); + checkFooBoxIsOk(failsOnEcmaV5(), "KT-740-3.kt"); } public void testFunInConstructor() throws Exception { @@ -107,11 +110,11 @@ public final class MiscTest extends AbstractExpressionTest { } public void testExtensionLiteralCreatedAtNamespaceLevel() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testTemporaryVariableCreatedInNamespaceInitializer() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testWhenReturnedWithoutBlock() throws Exception { @@ -127,7 +130,7 @@ public final class MiscTest extends AbstractExpressionTest { } public void testKt1865() throws Exception { - checkFooBoxIsTrue("KT-1865.kt"); + checkFooBoxIsTrue("KT-1865.kt", EcmaVersion.all()); } public void testMainFunInNestedNamespace() throws Exception { diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/NamespaceTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/NamespaceTest.java index 1686fe1fa2a..15932fa4c4c 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/NamespaceTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/NamespaceTest.java @@ -35,14 +35,17 @@ public final class NamespaceTest extends SingleFileTranslationTest { } public void testDeeplyNestedNamespaceFunctionCalled() throws Exception { - runFunctionOutputTest("deeplyNestedNamespaceFunctionCalled.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true); + runFunctionOutputTest("deeplyNestedNamespaceFunctionCalled.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true + ); } public void testClassCreatedInDeeplyNestedNamespace() throws Exception { - runFunctionOutputTest("classCreatedInDeeplyNestedNamespace.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true); + runFunctionOutputTest("classCreatedInDeeplyNestedNamespace.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true + ); } public void testInitializersOfNestedNamespacesExecute() throws Exception { - runFunctionOutputTest("initializersOfNestedNamespacesExecute.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true); + runFunctionOutputTest("initializersOfNestedNamespacesExecute.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true + ); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java index c85eae2ed83..874b23b206a 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java @@ -18,6 +18,7 @@ package org.jetbrains.k2js.test.semantics; import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; +import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.test.SingleFileTranslationTest; import org.jetbrains.k2js.test.utils.JsTestUtils; @@ -59,6 +60,6 @@ public final class NativeInteropTest extends SingleFileTranslationTest { } public void testKt1519() throws Exception { - checkFooBoxIsTrue("KT-1519.kt"); + checkFooBoxIsTrue("KT-1519.kt", EcmaVersion.all()); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/OperatorOverloadingTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/OperatorOverloadingTest.java index 9b2a0c962b0..d23b2b51044 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/OperatorOverloadingTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/OperatorOverloadingTest.java @@ -18,6 +18,8 @@ package org.jetbrains.k2js.test.semantics; import org.jetbrains.k2js.test.SingleFileTranslationTest; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov */ @@ -58,7 +60,7 @@ public final class OperatorOverloadingTest extends SingleFileTranslationTest { public void testOperatorOverloadOnPropertyCallGetterAndSetterOnlyOnce() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/PropertyAccessTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/PropertyAccessTest.java index 7bad8bd9f53..388a70c7a83 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/PropertyAccessTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/PropertyAccessTest.java @@ -18,6 +18,8 @@ package org.jetbrains.k2js.test.semantics; import org.jetbrains.k2js.test.SingleFileTranslationTest; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov */ @@ -43,12 +45,12 @@ public final class PropertyAccessTest extends SingleFileTranslationTest { public void testCustomGetter() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testCustomSetter() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testNamespacePropertyInitializer() throws Exception { @@ -61,7 +63,7 @@ public final class PropertyAccessTest extends SingleFileTranslationTest { } public void testNamespaceCustomAccessors() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } @@ -72,5 +74,4 @@ public final class PropertyAccessTest extends SingleFileTranslationTest { public void testExtensionLiteralSafeCall() throws Exception { fooBoxTest(); } - } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/RangeTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/RangeTest.java index 10a497e40a9..23bbd0a6938 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/RangeTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/RangeTest.java @@ -18,6 +18,8 @@ package org.jetbrains.k2js.test.semantics; import org.jetbrains.k2js.test.SingleFileTranslationTest; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov */ @@ -28,12 +30,12 @@ public final class RangeTest extends SingleFileTranslationTest { } public void testExplicitRange() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } public void testRangeSugarSyntax() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } 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 99134a4d7e2..aac8760f744 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,6 +18,7 @@ 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; @@ -38,18 +39,19 @@ public final class SimpleTest extends SingleFileTranslationTest { @Override public void runTest() throws Exception { - checkFooBoxIsTrue(filename); + checkFooBoxIsTrue(filename, EcmaVersion.all()); } public static Test suite() throws Exception { - return TranslatorTestCaseBuilder.suiteForDirectory(BasicTest.pathToTestFilesRoot() + "simple/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() { - @NotNull - @Override - public Test createTest(@NotNull String filename) { - SimpleTest examplesTest = new SimpleTest(filename); - examplesTest.setName(filename); - return examplesTest; - } - }); + return TranslatorTestCaseBuilder + .suiteForDirectory(BasicTest.pathToTestFilesRoot() + "simple/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() { + @NotNull + @Override + public Test createTest(@NotNull String filename) { + SimpleTest examplesTest = new SimpleTest(filename); + examplesTest.setName(filename); + return examplesTest; + } + }); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StandardClassesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StandardClassesTest.java index 8a02744a4ac..0bf924d4c6f 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StandardClassesTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StandardClassesTest.java @@ -18,6 +18,8 @@ package org.jetbrains.k2js.test.semantics; import org.jetbrains.k2js.test.SingleFileTranslationTest; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov */ @@ -43,7 +45,7 @@ public final class StandardClassesTest extends SingleFileTranslationTest { public void testArrayFunctionConstructor() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } @@ -53,13 +55,13 @@ public final class StandardClassesTest extends SingleFileTranslationTest { //TODO: this feature in not supported for some time //TODO: support it. Probably configurable. -// (expected = JavaScriptException.class) -// public void arrayThrowsExceptionOnOOBaccess() throws Exception { -// fooBoxTest(); -// } + // (expected = JavaScriptException.class) + // public void arrayThrowsExceptionOnOOBaccess() throws Exception { + // fooBoxTest(); + // } public void testArraysIterator() throws Exception { - fooBoxTest(); + fooBoxTest(failsOnEcmaV5()); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/WebDemoExamples2Test.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/WebDemoExamples2Test.java index 28afb839d55..739b5e1dc8a 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/WebDemoExamples2Test.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/WebDemoExamples2Test.java @@ -18,6 +18,8 @@ package org.jetbrains.k2js.test.semantics; import org.jetbrains.k2js.test.SingleFileTranslationTest; +import static org.jetbrains.k2js.test.utils.JsTestUtils.failsOnEcmaV5; + /** * @author Pavel Talanov */ @@ -33,11 +35,11 @@ public final class WebDemoExamples2Test extends SingleFileTranslationTest { } public void testLife() throws Exception { - performTestWithMain("life", "", "2"); + performTestWithMain(failsOnEcmaV5(), "life", "", "2"); } public void testBuilder() throws Exception { - performTestWithMain("builder", ""); - performTestWithMain("builder", "1", "over9000"); + performTestWithMain(failsOnEcmaV5(), "builder", ""); + performTestWithMain(failsOnEcmaV5(), "builder", "1", "over9000"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/utils/JsTestUtils.java b/js/js.tests/test/org/jetbrains/k2js/test/utils/JsTestUtils.java index fdbca4eb642..2229ea0eb3e 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/utils/JsTestUtils.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/utils/JsTestUtils.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.EnumSet; import java.util.List; /** @@ -34,6 +35,23 @@ public final class JsTestUtils { private JsTestUtils() { } + @NotNull + public static EnumSet failsOn(EcmaVersion... versions) { + EnumSet result = EcmaVersion.all(); + for (EcmaVersion version : versions) { + boolean success = result.remove(version); + assert success; + } + return result; + } + + @NotNull + public static EnumSet failsOnEcmaV5() { + return failsOn(EcmaVersion.v5); + } + + + @NotNull public static String convertFileNameToDotJsFile(@NotNull String filename, EcmaVersion ecmaVersion) { String postFix = "_" + ecmaVersion.toString() + ".js"; int index = filename.lastIndexOf('.');