Mark the tests which are failing with EcmaVersion.v5 and exclude them

This commit is contained in:
pTalanov
2012-05-15 20:25:44 +04:00
parent 43c168baef
commit 6d414ba222
14 changed files with 148 additions and 69 deletions
@@ -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<EcmaVersion> ecmaVersions) throws Exception {
List<String> 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<EcmaVersion> 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));
}
@@ -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<EcmaVersion> ecmaVersions = EcmaVersion.all();
runFunctionOutputTest(EcmaVersion.all(), kotlinFilename, namespaceName, functionName, expectedResult);
}
protected void runFunctionOutputTest(@NotNull EnumSet<EcmaVersion> 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<EcmaVersion> 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<EcmaVersion> ecmaVersions) throws Exception {
checkFooBoxIsTrue(getTestName(true) + ".kt", ecmaVersions);
}
protected void checkOutput(@NotNull String kotlinFilename, @NotNull String expectedResult, @NotNull String... args) throws Exception {
EnumSet<EcmaVersion> ecmaVersions = EcmaVersion.all();
protected void checkFooBoxIsOk(@NotNull String filename) throws Exception {
checkFooBoxIsOk(EcmaVersion.all(), filename);
}
protected void checkFooBoxIsOk(@NotNull EnumSet<EcmaVersion> 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<EcmaVersion> 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<EcmaVersion> 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);
}
}
@@ -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;
}
});
}
}
@@ -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());
}
}
@@ -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
* <p/>
@@ -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 {
@@ -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
);
}
}
@@ -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());
}
}
@@ -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());
}
@@ -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();
}
}
@@ -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());
}
@@ -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;
}
});
}
}
@@ -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());
}
}
@@ -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");
}
}
@@ -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<EcmaVersion> failsOn(EcmaVersion... versions) {
EnumSet<EcmaVersion> result = EcmaVersion.all();
for (EcmaVersion version : versions) {
boolean success = result.remove(version);
assert success;
}
return result;
}
@NotNull
public static EnumSet<EcmaVersion> failsOnEcmaV5() {
return failsOn(EcmaVersion.v5);
}
@NotNull
public static String convertFileNameToDotJsFile(@NotNull String filename, EcmaVersion ecmaVersion) {
String postFix = "_" + ecmaVersion.toString() + ".js";
int index = filename.lastIndexOf('.');