JS: move more test to box tests

This commit is contained in:
Alexey Andreev
2016-08-30 17:07:29 +03:00
parent 34bf3e6e56
commit 9da1a50cae
68 changed files with 465 additions and 355 deletions
@@ -82,7 +82,6 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
private static final String OUT = "out/";
private static final String EXPECTED = "expected/";
private static final String COMMON_FILES_DIR = "_commonFiles/";
public static final String MODULE_EMULATION_FILE = TEST_DATA_DIR_PATH + "/moduleEmulation.js";
public static final String TEST_MODULE = "JS_TESTS";
public static final String TEST_PACKAGE = "foo";
@@ -104,16 +103,9 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), new CompilerConfiguration(), EnvironmentConfigFiles.JS_CONFIG_FILES);
}
protected boolean shouldCreateOut() {
return true;
}
@Override
public void setUp() throws Exception {
super.setUp();
if (!shouldCreateOut()) {
return;
}
File outDir = new File(getOutputPath());
KotlinTestUtils.mkdirs(outDir);
@@ -122,8 +114,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
@Override
protected void tearDown() throws Exception {
super.tearDown();
//noinspection ConstantConditions,PointlessBooleanExpression
if (!shouldCreateOut() || !DELETE_OUT) {
if (!DELETE_OUT) {
return;
}
File outDir = new File(getOutputPath());
@@ -158,7 +149,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
generateJavaScriptFiles(files, testName, mainCallParameters, ecmaVersions, TEST_MODULE, null);
}
protected void generateJavaScriptFiles(
private void generateJavaScriptFiles(
@NotNull List<String> files,
@NotNull String testName,
@NotNull MainCallParameters mainCallParameters,
@@ -171,7 +162,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
}
}
protected void generateJavaScriptFiles(
private void generateJavaScriptFiles(
@NotNull List<String> files,
@NotNull String testName,
@NotNull MainCallParameters mainCallParameters,
@@ -190,11 +181,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
translateFiles(jetFiles, outputFile, mainCallParameters, config);
}
protected String getModuleDirectoryName(String dirName, String moduleName) {
return dirName + File.separator + moduleName;
}
protected void translateFiles(
private void translateFiles(
@NotNull List<KtFile> jetFiles,
@NotNull File outputFile,
@NotNull MainCallParameters mainCallParameters,
@@ -241,11 +228,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
return false;
}
protected boolean shouldGenerateMetaInfo() {
return false;
}
protected void processJsProgram(@NotNull JsProgram program, @NotNull List<KtFile> jetFiles) throws Exception {
private static void processJsProgram(@NotNull JsProgram program, @NotNull List<KtFile> jetFiles) throws Exception {
for (KtFile file : jetFiles) {
String text = file.getText();
DirectiveTestUtils.processDirectives(program, text);
@@ -304,7 +287,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
// helpers
@NotNull
protected final String pathToTestDir() {
private String pathToTestDir() {
return TEST_DATA_DIR_PATH + relativePathToTestDir;
}
@@ -345,12 +328,10 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
configuration.put(JSConfigurationKeys.TARGET, ecmaVersion);
configuration.put(JSConfigurationKeys.SOURCE_MAP, shouldGenerateSourceMap());
configuration.put(JSConfigurationKeys.META_INFO, shouldGenerateMetaInfo());
configuration.put(JSConfigurationKeys.META_INFO, false);
configuration.put(JSConfigurationKeys.UNIT_TEST_CONFIG, shouldBeTranslateAsUnitTestClass());
setupConfig(configuration);
return new LibrarySourcesConfig(project, configuration);
}
@@ -364,17 +345,13 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
return false;
}
protected void setupConfig(@NotNull CompilerConfiguration configuration) {
// Do nothing by default, expect inheritors to implement this method
}
@NotNull
protected String getOutputPath() {
private String getOutputPath() {
return pathToTestDir() + OUT;
}
@NotNull
protected String getInputPath() {
private String getInputPath() {
return pathToTestDir() + CASES;
}
@@ -419,7 +396,6 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
protected String getPackageName(@NotNull String filename) throws IOException {
String content = FileUtil.loadFile(new File(filename), true);
KtPsiFactory psiFactory = new KtPsiFactory(getProject());
KtFile jetFile = psiFactory.createFile(content);
KtFile ktFile = psiFactory.createFile(content);
return getPackageName(ktFile);
}
@@ -63,7 +63,7 @@ public abstract class SingleFileTranslationTest extends BasicTest {
runFunctionOutputTestByPaths(ecmaVersions, Collections.singletonList(kotlinFilePath), packageName, functionName, expectedResult);
}
protected void runFunctionOutputTestByPaths(
private void runFunctionOutputTestByPaths(
@NotNull Iterable<EcmaVersion> ecmaVersions,
@NotNull List<String> kotlinFilePaths,
@NotNull String packageName,
@@ -76,22 +76,6 @@ public abstract class SingleFileTranslationTest extends BasicTest {
runRhinoTests(testName, ecmaVersions, checker);
}
private void checkFooBoxIsTrue(@NotNull String filename, @NotNull Iterable<EcmaVersion> ecmaVersions) throws Exception {
runFunctionOutputTest(ecmaVersions, filename, TEST_PACKAGE, TEST_FUNCTION, true);
}
protected void checkFooBoxIsTrue(@NotNull String filename) throws Exception {
runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, filename, TEST_PACKAGE, TEST_FUNCTION, true);
}
protected void fooBoxTest() throws Exception {
checkFooBoxIsTrue(getTestName(true) + ".kt", DEFAULT_ECMA_VERSIONS);
}
protected void checkFooBoxIsOk() throws Exception {
checkFooBoxIsOk(getTestName(true) + ".kt");
}
protected void checkFooBoxIsOk(@NotNull String filename) throws Exception {
checkFooBoxIsOkByPath(getInputFilePath(filename));
}
@@ -101,10 +85,6 @@ public abstract class SingleFileTranslationTest extends BasicTest {
runFunctionOutputTestByPath(DEFAULT_ECMA_VERSIONS, filePath, TEST_PACKAGE, TEST_FUNCTION, "OK");
}
protected void checkBlackBoxIsOkByPath(@NotNull String filePath) throws Exception {
runFunctionOutputTestByPath(DEFAULT_ECMA_VERSIONS, filePath, getPackageName(filePath), TEST_FUNCTION, "OK");
}
protected void checkOutput(@NotNull String kotlinFilename,
@NotNull String expectedResult,
@NotNull String... args) throws Exception {
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2015 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;
public final class AbstractListTest extends JavaClassesTest {
public AbstractListTest() {
super("abstractList/");
}
public void testIterator() throws Exception {
checkFooBoxIsOk();
}
}
@@ -1,95 +0,0 @@
/*
* Copyright 2010-2015 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 org.mozilla.javascript.JavaScriptException;
public final class ArrayListTest extends JavaClassesTest {
public ArrayListTest() {
super("arrayList/");
}
public void testEmptyList() throws Exception {
fooBoxTest();
}
public void testAccess() throws Exception {
fooBoxTest();
}
public void testIsEmpty() throws Exception {
fooBoxTest();
}
public void testArrayAccess() throws Exception {
fooBoxTest();
}
public void testIterate() throws Exception {
fooBoxTest();
}
public void testRemove() throws Exception {
fooBoxTest();
}
public void testRemoveWithIndexOutOfBounds() throws Exception {
fooBoxTest();
}
public void testToArray() throws Exception {
fooBoxTest();
}
public void testIndexOOB() throws Exception {
try {
fooBoxTest();
fail();
} catch (JavaScriptException e) {
// Ignored
}
}
public void testMisc() throws Exception {
fooBoxTest();
}
public void testConstructWithCapacity() throws Exception {
fooBoxTest();
}
public void testConstructWithSideEffectParam() throws Exception {
fooBoxTest();
}
public void testIndexOf() throws Exception {
checkFooBoxIsOk();
}
public void testContainsAll() throws Exception {
checkFooBoxIsOk();
}
public void testRemoveAll() throws Exception {
checkFooBoxIsOk();
}
public void testRetainAll() throws Exception {
checkFooBoxIsOk();
}
}
@@ -1388,6 +1388,189 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
}
@TestMetadata("js/js.translator/testData/box/examples")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Examples extends AbstractBoxJsTest {
public void testAllFilesPresentInExamples() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/examples"), Pattern.compile("^([^_](.+))\\.kt$"), true);
}
@TestMetadata("basicmethod.kt")
public void testBasicmethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/basicmethod.kt");
doTest(fileName);
}
@TestMetadata("basicproperty.kt")
public void testBasicproperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/basicproperty.kt");
doTest(fileName);
}
@TestMetadata("classObject.kt")
public void testClassObject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/classObject.kt");
doTest(fileName);
}
@TestMetadata("closureWithParameter.kt")
public void testClosureWithParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/closureWithParameter.kt");
doTest(fileName);
}
@TestMetadata("closureWithParameterAndBoxing.kt")
public void testClosureWithParameterAndBoxing() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/closureWithParameterAndBoxing.kt");
doTest(fileName);
}
@TestMetadata("doubleEnclosedLocalVariable.kt")
public void testDoubleEnclosedLocalVariable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/doubleEnclosedLocalVariable.kt");
doTest(fileName);
}
@TestMetadata("enclosed.kt")
public void testEnclosed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/enclosed.kt");
doTest(fileName);
}
@TestMetadata("enclosingLocalVariable.kt")
public void testEnclosingLocalVariable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/enclosingLocalVariable.kt");
doTest(fileName);
}
@TestMetadata("extensionClosure.kt")
public void testExtensionClosure() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/extensionClosure.kt");
doTest(fileName);
}
@TestMetadata("funDelegation.kt")
public void testFunDelegation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/funDelegation.kt");
doTest(fileName);
}
@TestMetadata("incrementProperty.kt")
public void testIncrementProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/incrementProperty.kt");
doTest(fileName);
}
@TestMetadata("inheritance.kt")
public void testInheritance() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/inheritance.kt");
doTest(fileName);
}
@TestMetadata("inheritedInnerClass.kt")
public void testInheritedInnerClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/inheritedInnerClass.kt");
doTest(fileName);
}
@TestMetadata("inheritedMethod.kt")
public void testInheritedMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/inheritedMethod.kt");
doTest(fileName);
}
@TestMetadata("initializerBlock.kt")
public void testInitializerBlock() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/initializerBlock.kt");
doTest(fileName);
}
@TestMetadata("initializerBlockDImpl.kt")
public void testInitializerBlockDImpl() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/initializerBlockDImpl.kt");
doTest(fileName);
}
@TestMetadata("innerClass.kt")
public void testInnerClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/innerClass.kt");
doTest(fileName);
}
@TestMetadata("kt242.kt")
public void testKt242() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/kt242.kt");
doTest(fileName);
}
@TestMetadata("newInstanceDefaultConstructor.kt")
public void testNewInstanceDefaultConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/newInstanceDefaultConstructor.kt");
doTest(fileName);
}
@TestMetadata("overloadBinaryOperator.kt")
public void testOverloadBinaryOperator() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/overloadBinaryOperator.kt");
doTest(fileName);
}
@TestMetadata("overloadPlusAssignReturn.kt")
public void testOverloadPlusAssignReturn() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/overloadPlusAssignReturn.kt");
doTest(fileName);
}
@TestMetadata("overloadPlusToPlusAssign.kt")
public void testOverloadPlusToPlusAssign() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/overloadPlusToPlusAssign.kt");
doTest(fileName);
}
@TestMetadata("overloadUnaryOperator.kt")
public void testOverloadUnaryOperator() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/overloadUnaryOperator.kt");
doTest(fileName);
}
@TestMetadata("propertyDelegation.kt")
public void testPropertyDelegation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/propertyDelegation.kt");
doTest(fileName);
}
@TestMetadata("propertyInInitializer.kt")
public void testPropertyInInitializer() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/propertyInInitializer.kt");
doTest(fileName);
}
@TestMetadata("rightHandOverride.kt")
public void testRightHandOverride() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/rightHandOverride.kt");
doTest(fileName);
}
@TestMetadata("simplestClosure.kt")
public void testSimplestClosure() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/simplestClosure.kt");
doTest(fileName);
}
@TestMetadata("simplestClosureAndBoxing.kt")
public void testSimplestClosureAndBoxing() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/simplestClosureAndBoxing.kt");
doTest(fileName);
}
@TestMetadata("traitproperty.kt")
public void testTraitproperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/examples/traitproperty.kt");
doTest(fileName);
}
}
@TestMetadata("js/js.translator/testData/box/expression")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -4322,6 +4505,135 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
}
@TestMetadata("js/js.translator/testData/box/java")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Java extends AbstractBoxJsTest {
public void testAllFilesPresentInJava() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java"), Pattern.compile("^([^_](.+))\\.kt$"), true);
}
@TestMetadata("js/js.translator/testData/box/java/abstractList")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class AbstractList extends AbstractBoxJsTest {
public void testAllFilesPresentInAbstractList() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java/abstractList"), Pattern.compile("^([^_](.+))\\.kt$"), true);
}
@TestMetadata("iterator.kt")
public void testIterator() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/abstractList/iterator.kt");
doTest(fileName);
}
}
@TestMetadata("js/js.translator/testData/box/java/arrayList")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ArrayList extends AbstractBoxJsTest {
@TestMetadata("access.kt")
public void testAccess() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/access.kt");
doTest(fileName);
}
public void testAllFilesPresentInArrayList() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java/arrayList"), Pattern.compile("^([^_](.+))\\.kt$"), true);
}
@TestMetadata("arrayAccess.kt")
public void testArrayAccess() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/arrayAccess.kt");
doTest(fileName);
}
@TestMetadata("constructWithCapacity.kt")
public void testConstructWithCapacity() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/constructWithCapacity.kt");
doTest(fileName);
}
@TestMetadata("constructWithSideEffectParam.kt")
public void testConstructWithSideEffectParam() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/constructWithSideEffectParam.kt");
doTest(fileName);
}
@TestMetadata("containsAll.kt")
public void testContainsAll() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/containsAll.kt");
doTest(fileName);
}
@TestMetadata("emptyList.kt")
public void testEmptyList() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/emptyList.kt");
doTest(fileName);
}
@TestMetadata("indexOOB.kt")
public void testIndexOOB() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/indexOOB.kt");
doTest(fileName);
}
@TestMetadata("indexOf.kt")
public void testIndexOf() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/indexOf.kt");
doTest(fileName);
}
@TestMetadata("isEmpty.kt")
public void testIsEmpty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/isEmpty.kt");
doTest(fileName);
}
@TestMetadata("iterate.kt")
public void testIterate() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/iterate.kt");
doTest(fileName);
}
@TestMetadata("misc.kt")
public void testMisc() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/misc.kt");
doTest(fileName);
}
@TestMetadata("remove.kt")
public void testRemove() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/remove.kt");
doTest(fileName);
}
@TestMetadata("removeAll.kt")
public void testRemoveAll() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/removeAll.kt");
doTest(fileName);
}
@TestMetadata("removeWithIndexOutOfBounds.kt")
public void testRemoveWithIndexOutOfBounds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/removeWithIndexOutOfBounds.kt");
doTest(fileName);
}
@TestMetadata("retainAll.kt")
public void testRetainAll() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/retainAll.kt");
doTest(fileName);
}
@TestMetadata("toArray.kt")
public void testToArray() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/java/arrayList/toArray.kt");
doTest(fileName);
}
}
}
@TestMetadata("js/js.translator/testData/box/jsCode")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1,53 +0,0 @@
/*
* Copyright 2010-2015 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 junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.js.test.SingleFileTranslationTest;
import org.jetbrains.kotlin.js.translate.context.Namer;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class ExamplesTest extends SingleFileTranslationTest {
@NotNull
private final String filename;
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
public ExamplesTest(@NotNull String filename) {
super("examples/");
this.filename = filename;
}
@Override
public void runTest() throws Exception {
runFunctionOutputTest(filename, Namer.getRootPackageName(), TEST_FUNCTION, "OK");
}
public static Test suite() throws Exception {
return TranslatorTestCaseBuilder
.suiteForDirectory(TEST_DATA_DIR_PATH + "examples/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public Test createTest(@NotNull String filename) {
ExamplesTest examplesTest = new ExamplesTest(filename);
examplesTest.setName(filename);
return examplesTest;
}
});
}
}
@@ -1,27 +0,0 @@
/*
* Copyright 2010-2015 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 org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.js.test.SingleFileTranslationTest;
public abstract class JavaClassesTest extends SingleFileTranslationTest {
public JavaClassesTest(@NotNull String main) {
super("java/" + main);
}
}
@@ -42,4 +42,8 @@ public final class PackageTest extends SingleFileTranslationTest {
public void testInitializersOfNestedPackagesExecute() throws Exception {
runFunctionOutputTest("initializersOfNestedPackagesExecute.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", TEST_FUNCTION, true);
}
public void testMainFunInNestedPackage() throws Exception {
checkOutput("mainFunInNestedPackage.kt", "ayee");
}
}
@@ -19,8 +19,17 @@ package org.jetbrains.kotlin.js.test.semantics
import org.jetbrains.kotlin.js.test.BasicBoxTest
abstract class BorrowedTest(relativePath: String) : BasicBoxTest(
"compiler/testData/codegen/box/" + relativePath,
BasicBoxTest.TEST_DATA_DIR_PATH + relativePath + "out/"
"compiler/testData/codegen/box/$relativePath",
"${BasicBoxTest.TEST_DATA_DIR_PATH}/out/jvm/box/$relativePath/"
) {
init {
additionalCommonFileDirectories += BasicBoxTest.TEST_DATA_DIR_PATH + relativePath + "/_commonFiles/"
}
}
abstract class BorrowedInlineTest(relativePath: String) : BasicBoxTest(
"compiler/testData/codegen/boxInline/$relativePath",
"${BasicBoxTest.TEST_DATA_DIR_PATH}/out/jvm/boxInline/$relativePath/"
) {
init {
additionalCommonFileDirectories += BasicBoxTest.TEST_DATA_DIR_PATH + relativePath + "/_commonFiles/"
@@ -29,14 +38,14 @@ abstract class BorrowedTest(relativePath: String) : BasicBoxTest(
abstract class AbstractBoxJsTest() : BasicBoxTest(
BasicBoxTest.TEST_DATA_DIR_PATH + "box/",
BasicBoxTest.TEST_DATA_DIR_PATH + "out/"
BasicBoxTest.TEST_DATA_DIR_PATH + "out/box/"
)
abstract class AbstractBridgeTest : BorrowedTest("bridges/")
abstract class AbstractCompanionObjectTest : BorrowedTest("objectIntrinsics/")
abstract class AbstractFunctionExpressionTest : BorrowedTest("functionExpression/")
abstract class AbstractFunctionExpressionTest : BorrowedTest("functions/functionExpression/")
abstract class AbstractSecondaryConstructorTest : BorrowedTest("secondaryConstructors/")
@@ -48,6 +57,6 @@ abstract class AbstractSuperTest : BorrowedTest("super/")
abstract class AbstractLocalClassesTest : BorrowedTest("localClasses/")
abstract class AbstractNonLocalReturnsTest : BorrowedTest("inline.generated/nonLocalReturns/")
abstract class AbstractNonLocalReturnsTest : BorrowedInlineTest("nonLocalReturns/")
abstract class AbstractTypeAliasesTests : BorrowedTest("typealias/")
@@ -18,7 +18,7 @@ open class N() : M(), K {
override var y = 200
open class C() : K {
inner open class C() : K {
fun test1() = x()
fun test2() = super<M>@N.x()
fun test3() = super<K>@N.x()
@@ -2,10 +2,10 @@ import java.util.*
import java.io.*
class World() {
public val items: ArrayList<Item> = ArrayList<Item>
public val items: ArrayList<Item> = ArrayList<Item>()
class Item() {
{
inner class Item() {
init {
items.add(this)
}
}
@@ -13,7 +13,7 @@ class World() {
val foo = Item()
}
fun box(): String {
fun box() : String {
val w = World()
if (w.items.size != 1) return "fail"
return "OK"
@@ -1,5 +1,5 @@
class Outer(val foo: StringBuilder) {
class Inner() {
inner class Inner() {
fun len(): Int {
return foo.length
}
@@ -1,10 +1,10 @@
class Outer() {
val s = "xyzzy"
open class InnerBase(public val name: String) {
open inner class InnerBase(public val name: String) {
}
class InnerDerived() : InnerBase(s) {
inner class InnerDerived() : InnerBase(s) {
}
val x = InnerDerived()
+14
View File
@@ -0,0 +1,14 @@
package foo
import java.util.ArrayList;
fun box(): String {
val a = ArrayList<Int>();
a.add(1)
a.add(2)
if (a.size != 2) return "fail1: ${a.size}"
if (a.get(1) != 2) return "fail2"
if (a.get(0) != 1) return "fail3"
return "OK"
}
@@ -0,0 +1,15 @@
package foo
import java.util.ArrayList;
fun box(): String {
val a = ArrayList<Int>();
a.add(1)
a.add(2)
a[1] = 100
if (a.size != 2) return "fail1: ${a.size}"
if (a[1] != 100) return "fail2"
if (a[0] != 1) return "fail3"
return "OK"
}
@@ -0,0 +1,8 @@
package foo
import java.util.ArrayList
fun box(): String {
val al = ArrayList<Int>(10)
return if (al.size == 0) "OK" else "fail: ${al.size}"
}
@@ -8,7 +8,10 @@ fun withSideEffect(v: Int): Int {
return v
}
fun box(): Boolean {
fun box(): String {
val al = ArrayList<Int>(withSideEffect(2))
return al.size == 0 && baz == 2
if (al.size != 0) return "fail1: ${al.size}"
if (baz != 2) return "fail2: $baz"
return "OK"
}
@@ -0,0 +1,8 @@
package foo
import java.util.ArrayList;
fun box(): String {
val a = ArrayList<Int>();
return if (a.size == 0) "OK" else "fail: ${a.size}"
}
@@ -0,0 +1,18 @@
package foo
import java.util.ArrayList;
fun box(): String {
val arr = ArrayList<Int>();
var i = 0;
while (i++ < 10) {
arr.add(i);
}
try {
if (arr[10] == 11) return "fail1"
}
catch (e: Exception) {
return "OK"
}
return "fail2"
}
+11
View File
@@ -0,0 +1,11 @@
package foo
import java.util.ArrayList;
fun box(): String {
val a = ArrayList<Int>();
a.add(3)
if (a.isEmpty()) return "fail1"
if (!ArrayList<Int>().isEmpty()) return "fail2"
return "OK"
}
@@ -2,7 +2,7 @@ package foo
import java.util.ArrayList;
fun box(): Boolean {
fun box(): String {
var i = 0
val arr = ArrayList<Int>();
while (i++ < 10) {
@@ -12,5 +12,8 @@ fun box(): Boolean {
for (a in arr) {
sum += a;
}
return (sum == 55) && (arr.size == 10)
if (sum != 55) return "fail1: $sum"
if (arr.size != 10) return "fail2: ${arr.size}"
return "OK"
}
@@ -2,7 +2,7 @@ package foo
import java.util.ArrayList
fun box(): Boolean {
fun box(): String {
var i = 0
val list = ArrayList<Int>()
while (i++ < 3) {
@@ -15,7 +15,7 @@ fun box(): Boolean {
list.add(1, 500)
// test contains, addAll
if (!list.contains(500) || list.contains(600) || list.addAll(ArrayList<Int>())) {
return false;
return "fail1"
}
val a = ArrayList<Int>()
@@ -25,11 +25,11 @@ fun box(): Boolean {
b.add(4)
a.addAll(b)
if (a[0] != 3 || a[1] != 4) {
return false
return "fail2"
}
if (a.isEmpty() || !ArrayList<Int>().isEmpty()) {
return false
return "fail2"
}
assertNotEquals(a, b, "a != b")
@@ -45,5 +45,6 @@ fun box(): Boolean {
assertArrayEquals(arrayOf(1, 500, 2, 3), list.toTypedArray(), "list.toTypedArray()")
assertEquals("[1,500,2,3]", JSON.stringify(list), "JSON.stringify(list)")
assertEquals("[1, 500, 2, 3]", list.toString(), "list.toString()")
return true;
return "OK"
}
+22
View File
@@ -0,0 +1,22 @@
package foo
import java.util.ArrayList
fun box(): String {
val arr = ArrayList<Int>()
for (i in 0..5) {
arr.add(i)
}
val removedElement = arr.removeAt(2)
val removed = arr.remove(4)
if (arr.size != 4) return "fail1: ${arr.size}"
if (removedElement != 2) return "fail2: ${removedElement}"
if (!removed) return "fail3"
if (arr[0] != 0) return "fail4: ${arr[0]}"
if (arr[1] != 1) return "fail5: ${arr[1]}"
if (arr[2] != 3) return "fail6: ${arr[2]}"
if (arr[3] != 5) return "fail7: ${arr[3]}"
return "OK"
}
@@ -2,7 +2,7 @@ package foo
import java.util.ArrayList
fun box(): Boolean {
fun box(): String {
var threwForEmptyList = false
val arr = ArrayList<Int>()
@@ -26,5 +26,5 @@ fun box(): Boolean {
threwForFilled = true
}
return threwForEmptyList && threwForFilled
return if (threwForEmptyList && threwForFilled) "OK" else "fail"
}
@@ -2,7 +2,7 @@ package foo
import java.util.ArrayList
fun box(): Boolean {
fun box(): String {
var i = 0
val list = ArrayList<Int>()
while (i++ < 3) {
@@ -13,5 +13,6 @@ fun box(): Boolean {
list.add(1, 500)
val array = list.toTypedArray()
return array[0] == 1 && array[1] == 500 && array[2] == 2 && array[3] == 3 && JSON.stringify(list) == "[1,500,2,3]";
return if (array[0] == 1 && array[1] == 500 && array[2] == 2 && array[3] == 3 && JSON.stringify(list) == "[1,500,2,3]") "OK" else "fail"
}
@@ -1,10 +0,0 @@
package foo
import java.util.ArrayList;
fun box(): Boolean {
val a = ArrayList<Int>();
a.add(1)
a.add(2)
return (a.size == 2) && (a.get(1) == 2) && (a.get(0) == 1);
}
@@ -1,11 +0,0 @@
package foo
import java.util.ArrayList;
fun box(): Boolean {
val a = ArrayList<Int>();
a.add(1)
a.add(2)
a[1] = 100
return (a.size == 2) && (a[1] == 100) && (a[0] == 1);
}
@@ -1,8 +0,0 @@
package foo
import java.util.ArrayList
fun box(): Boolean {
val al = ArrayList<Int>(10)
return al.size == 0
}
@@ -1,8 +0,0 @@
package foo
import java.util.ArrayList;
fun box(): Boolean {
val a = ArrayList<Int>();
return a.size == 0;
}
@@ -1,12 +0,0 @@
package foo
import java.util.ArrayList;
fun box(): Boolean {
val arr = ArrayList<Int>();
var i = 0;
while (i++ < 10) {
arr.add(i);
}
return (arr[10] == 11)
}
@@ -1,9 +0,0 @@
package foo
import java.util.ArrayList;
fun box(): Boolean {
val a = ArrayList<Int>();
a.add(3)
return !(a.isEmpty()) && (ArrayList<Int>().isEmpty());
}
@@ -1,14 +0,0 @@
package foo
import java.util.ArrayList
fun box(): Boolean {
val arr = ArrayList<Int>()
for (i in 0..5) {
arr.add(i)
}
val removedElement = arr.removeAt(2)
val removed = arr.remove(4)
return arr.size == 4 && removedElement == 2 && removed && arr[0] == 0 && arr[1] == 1 && arr[2] == 3 && arr[3] == 5
}