diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleFilesTranslationTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleFilesTranslationTest.java deleted file mode 100644 index eca192f183f..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleFilesTranslationTest.java +++ /dev/null @@ -1,62 +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; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.js.config.EcmaVersion; -import org.jetbrains.kotlin.js.facade.MainCallParameters; -import org.jetbrains.kotlin.js.test.rhino.RhinoFunctionResultChecker; - -import java.util.List; - -import static org.jetbrains.kotlin.js.test.utils.JsTestUtils.getAllFilesInDir; - -public abstract class MultipleFilesTranslationTest extends BasicTest { - - public MultipleFilesTranslationTest(@NotNull String main) { - super(main); - } - - @Override - protected void checkFooBoxIsOkByPath(String filePath) throws Exception { - runMultiFileTest(getTestName(true), TEST_PACKAGE, TEST_FUNCTION, "OK"); - } - - private void generateJsFromDir(@NotNull String dirName, @NotNull Iterable ecmaVersions) throws Exception { - List fullFilePaths = getAllFilesInDir(getInputFilePath(dirName)); - generateJavaScriptFiles(fullFilePaths, dirName, MainCallParameters.noCall(), ecmaVersions); - } - - private void runMultiFileTest( - @NotNull String dirName, @NotNull String packageName, - @NotNull String functionName, @NotNull Object expectedResult - ) throws Exception { - runMultiFileTests(DEFAULT_ECMA_VERSIONS, dirName, packageName, functionName, expectedResult); - } - - private void runMultiFileTests( - @NotNull Iterable ecmaVersions, - @NotNull String dirName, - @NotNull String packageName, - @NotNull String functionName, - @NotNull Object expectedResult - ) throws Exception { - generateJsFromDir(dirName, ecmaVersions); - runRhinoTests(dirName + ".kt", ecmaVersions, new RhinoFunctionResultChecker(TEST_MODULE, packageName, functionName, expectedResult)); - } -} - diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/AbstractExpressionTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/AbstractExpressionTest.java deleted file mode 100644 index 682f660d315..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/AbstractExpressionTest.java +++ /dev/null @@ -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 AbstractExpressionTest extends SingleFileTranslationTest { - - public AbstractExpressionTest(@NotNull String main) { - super("expression/" + main); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CompileMavenGeneratedJSLibrary.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CompileMavenGeneratedJSLibrary.java deleted file mode 100644 index 37e8f8b8f72..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CompileMavenGeneratedJSLibrary.java +++ /dev/null @@ -1,125 +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 com.google.common.collect.Lists; -import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.cli.common.ExitCode; -import org.jetbrains.kotlin.cli.js.K2JSCompiler; -import org.jetbrains.kotlin.js.config.EcmaVersion; -import org.jetbrains.kotlin.js.test.SingleFileTranslationTest; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Lets test compiling all the JS code thats used by the library-js-library from the maven build - * - * This test case isn't run by default but can only be ran after the maven build - * has completed so that there are various kotlin files to be compiled - */ -public class CompileMavenGeneratedJSLibrary extends SingleFileTranslationTest { - private static final String generatedJsDir = "libraries/tools/kotlin-js-library/target/"; - private static final String generatedJsDefinitionsDir = generatedJsDir + "generated-js-definitions"; - private final File generatedJsLibraryDir = new File(generatedJsDir + "generated-js-library"); - - public CompileMavenGeneratedJSLibrary() { - super("kotlin-js-library/"); - } - - public static void main(String[] args) throws Exception { - CompileMavenGeneratedJSLibrary test = new CompileMavenGeneratedJSLibrary(); - test.DISABLED_testGenerateTestCase(); - } - - public void testDummy() { - } - - public void DISABLED_testGenerateTestCase() throws Exception { - if (generatedJsLibraryDir.exists() && generatedJsLibraryDir.isDirectory()) { - generateJavaScriptFiles(DEFAULT_ECMA_VERSIONS, - "libraries/stdlib/test", - "collections/ArraysTest.kt", - "dom/DomTest.kt", - "js/MapTest.kt", - "js/JsDomTest.kt", - "collections/FunctionIteratorTest.kt", - "collections/IteratorsTest.kt", - "GetOrElseTest.kt", - "collections/ListTest.kt", - "collections/SetTest.kt", - "text/StringTest.kt"); - } - else { - System.out.println("Warning " + generatedJsLibraryDir + " does not exist - I guess you've not run the maven build in library/ yet?"); - } - } - - private void generateJavaScriptFiles( - @NotNull Iterable ecmaVersions, - @NotNull String sourceDir, - @NotNull String... stdLibFiles - ) throws Exception { - List files = Lists.newArrayList(); - - // now lets add all the files from the definitions and library - //addAllSourceFiles(files, generatedJsDefinitionsDir); - addAllSourceFiles(files, generatedJsLibraryDir); - - File stdlibDir = new File(sourceDir); - assertTrue("Cannot find stdlib test source: " + stdlibDir, stdlibDir.exists()); - for (String file : stdLibFiles) { - files.add(new File(stdlibDir, file).getPath()); - } - - // now lets try invoke the compiler - for (EcmaVersion version : ecmaVersions) { - String outputFile = getOutputFilePath(getTestName(false) + ".compiler.kt", version); - System.out.println("Compiling with version: " + version + " to: " + outputFile); - - List args = new ArrayList<>(Arrays.asList( - "-output", outputFile, - "-libraries", generatedJsDefinitionsDir, - "-verbose" - )); - args.addAll(files); - ExitCode answer = new K2JSCompiler().exec(System.out, ArrayUtil.toStringArray(args)); - - assertEquals("Compile failed", ExitCode.OK, answer); - } - } - - private static void addAllSourceFiles(List files, File dir) { - File[] children = dir.listFiles(); - if (children != null && children.length > 0) { - for (File child : children) { - if (child.isDirectory()) { - addAllSourceFiles(files, child); - } - else { - String name = child.getName(); - if (name.toLowerCase().endsWith(".kt")) { - files.add(child.getPath()); - } - } - } - } - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsUnitTestBase.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsUnitTestBase.java deleted file mode 100644 index 5df55874153..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsUnitTestBase.java +++ /dev/null @@ -1,109 +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 com.google.common.collect.Lists; -import junit.framework.Test; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.js.config.EcmaVersion; -import org.jetbrains.kotlin.js.facade.MainCallParameters; -import org.jetbrains.kotlin.js.test.MultipleFilesTranslationTest; -import org.jetbrains.kotlin.js.test.rhino.RhinoSystemOutputChecker; -import org.jetbrains.kotlin.js.test.rhino.RhinoUtils; -import org.jetbrains.kotlin.js.test.utils.JsUnitTestReporter; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public abstract class JsUnitTestBase extends MultipleFilesTranslationTest { - - @NotNull - private static final String JS_TESTS = TEST_DATA_DIR_PATH + "jsTester/"; - @NotNull - protected static final String JS_TESTS_KT = JS_TESTS + "jsTester.kt"; - @NotNull - protected static final String JS_TESTS_JS = JS_TESTS + "jsTester.js"; - //NOTE: we use this object to communicate test result from Rhino, it is not necessary to use global objects there - // we can inject those objects in JavaScript every time but this kind of solution will complicate logic a bit - @NotNull - private static final JsUnitTestReporter JS_UNIT_TEST_REPORTER = new JsUnitTestReporter(); - - public JsUnitTestBase() { - super("jsUnitTests/"); - } - - @NotNull - @Override - protected List additionalJsFiles(@NotNull EcmaVersion ecmaVersion) { - List result = Lists.newArrayList(super.additionalJsFiles(ecmaVersion)); - result.add(JS_TESTS_JS); - return result; - } - - @NotNull - @Override - protected List additionalKotlinFiles() { - List result = StdLibTestBase.removeAdHocAssertions(super.additionalKotlinFiles()); - result.add(JS_TESTS_KT); - result.add("libraries/stdlib/test/testUtils.kt"); - return result; - } - - @Override - protected boolean shouldBeTranslateAsUnitTestClass() { - return true; - } - - public void runTestFile(@NotNull String pathToTestFile) throws Exception { - Iterable versions = DEFAULT_ECMA_VERSIONS; - String testName = pathToTestFile.substring(pathToTestFile.lastIndexOf("/")); - - generateJavaScriptFiles(Collections.singletonList(pathToTestFile), testName, MainCallParameters.noCall(), versions); - runRhinoTests(testName, versions, new RhinoSystemOutputChecker("")); - } - - @NotNull - public static Test createTestSuiteForFile(@NotNull String file, @NotNull String... ignoreFailedTestCases) throws Exception { - performTests(file); - JS_UNIT_TEST_REPORTER.ignoreTests(ignoreFailedTestCases); - return JS_UNIT_TEST_REPORTER.createTestSuiteAndFlush(); - } - - private static void performTests(@NotNull String testFile) throws Exception { - //NOTE: well it doesn't - @SuppressWarnings("JUnitTestCaseWithNoTests") JsUnitTestBase runner = new JsUnitTestBase() { - - }; - try { - runner.setUp(); - runner.runTestFile(testFile); - } - finally { - runner.tearDown(); - } - } - - @Override - protected Map getRhinoTestVariables() throws Exception { - Map testVariables = new HashMap<>(); - testVariables.put(RhinoUtils.OPTIMIZATION_LEVEL_TEST_VARIABLE, RhinoUtils.OPTIMIZATION_OFF); - testVariables.put("jsTestReporter", JS_UNIT_TEST_REPORTER); - return testVariables; - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibBitwiseOperationsTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibBitwiseOperationsTest.java deleted file mode 100644 index a87333f3b0f..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibBitwiseOperationsTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2016 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; - -//NOTE: well, it has tests -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibBitwiseOperationsTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/numbers/BitwiseOperationsTest.kt"); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibIterableTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibIterableTest.java deleted file mode 100644 index df245d39338..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibIterableTest.java +++ /dev/null @@ -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 junit.framework.Test; - -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibIterableTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/collections/IterableTests.kt"); - } -} - diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibIteratorsTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibIteratorsTest.java deleted file mode 100644 index cdd23b8f481..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibIteratorsTest.java +++ /dev/null @@ -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 junit.framework.Test; - -//NOTE: well, it has tests -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibIteratorsTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/collections/IteratorsTest.kt"); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibJsArrayScriptTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibJsArrayScriptTest.java deleted file mode 100644 index 017c4ebdbf8..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibJsArrayScriptTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2016 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.rhino.CompositeRhinoResultsChecker; -import org.jetbrains.kotlin.js.test.rhino.RhinoFunctionResultChecker; -import org.jetbrains.kotlin.js.test.rhino.RhinoResultChecker; - -public class StdLibJsArrayScriptTest extends StdLibTestBase { - public void testArrayScriptTest() throws Exception { - performStdLibTest(DEFAULT_ECMA_VERSIONS, "libraries/stdlib/test", "js/JsArrayScript.kt"); - } - - @NotNull - @Override - protected RhinoResultChecker getResultChecker() { - return new CompositeRhinoResultsChecker( - new RhinoFunctionResultChecker(TEST_MODULE, "test.collections.js", "testSize", 3.0), - new RhinoFunctionResultChecker(TEST_MODULE, "test.collections.js", "testToListToString", "[]-[foo]-[foo, bar]") - ); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibJsCollectionsTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibJsCollectionsTest.java deleted file mode 100644 index 61643b4072f..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibJsCollectionsTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2016 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; - -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibJsCollectionsTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/js/JsCollectionsTest.kt"); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibListTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibListTest.java deleted file mode 100644 index b2edf79481b..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibListTest.java +++ /dev/null @@ -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 junit.framework.Test; - -//NOTE: well, it has tests -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibListTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/collections/ListSpecificTest.kt"); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibMapTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibMapTest.java deleted file mode 100644 index f02cb91f540..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibMapTest.java +++ /dev/null @@ -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 junit.framework.Test; - -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibMapTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/collections/MapTest.kt"); - } -} - diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibQUnitTestSupport.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibQUnitTestSupport.java deleted file mode 100644 index 8d582b43878..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibQUnitTestSupport.java +++ /dev/null @@ -1,47 +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 com.google.common.collect.Lists; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.js.config.EcmaVersion; -import org.jetbrains.kotlin.js.test.rhino.RhinoQUnitResultChecker; -import org.jetbrains.kotlin.js.test.rhino.RhinoResultChecker; - -import java.util.List; - -/** - * A base class for any JS compile test cases which should run the generated JS file as a QUnit test case - */ -public abstract class StdLibQUnitTestSupport extends StdLibTestBase { - - @Nullable - @Override - protected RhinoResultChecker getResultChecker() { - return new RhinoQUnitResultChecker(); - } - - @NotNull - @Override - protected List additionalJsFiles(@NotNull EcmaVersion ecmaVersion) { - List files = Lists.newArrayList(super.additionalJsFiles(ecmaVersion)); - files.add("js/js.translator/qunit/qunit.js"); - files.add("js/js.translator/qunit/headless.js"); - return files; - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibStringBuilderTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibStringBuilderTest.java deleted file mode 100644 index b35a80d46e0..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibStringBuilderTest.java +++ /dev/null @@ -1,26 +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; - -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibStringBuilderTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/text/StringBuilderTest.kt"); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibStringTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibStringTest.java deleted file mode 100644 index 1eafe04c477..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibStringTest.java +++ /dev/null @@ -1,26 +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; - -@SuppressWarnings("JUnitTestCaseWithNoTests") -public final class StdLibStringTest extends JsUnitTestBase { - public static Test suite() throws Exception { - return createTestSuiteForFile("libraries/stdlib/test/text/StringTest.kt"); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibTestBase.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibTestBase.java deleted file mode 100644 index c439d40f727..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibTestBase.java +++ /dev/null @@ -1,84 +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 com.google.common.collect.Lists; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.js.config.EcmaVersion; -import org.jetbrains.kotlin.js.facade.MainCallParameters; -import org.jetbrains.kotlin.js.test.SingleFileTranslationTest; -import org.jetbrains.kotlin.js.test.rhino.RhinoResultChecker; - -import java.io.File; -import java.util.Iterator; -import java.util.List; - -// TODO: should be dropped with derived classes? -abstract class StdLibTestBase extends SingleFileTranslationTest { - protected StdLibTestBase() { - super("stdlib/"); - } - - @Nullable - protected abstract RhinoResultChecker getResultChecker(); - - protected void performStdLibTest( - @NotNull Iterable ecmaVersions, - @NotNull String sourceDir, - @NotNull String... stdLibFiles - ) throws Exception { - List files = filesFromDir(sourceDir, stdLibFiles); - String testFileName = getTestName(true) + ".kt"; - - generateJavaScriptFiles(files, testFileName, MainCallParameters.noCall(), ecmaVersions); - - RhinoResultChecker checker = getResultChecker(); - if (checker != null) { - runRhinoTests(testFileName, ecmaVersions, checker); - } - } - - @NotNull - private static List filesFromDir(@NotNull String sourceDir, @NotNull String[] stdLibFiles) { - List files = Lists.newArrayList(); - File stdlibDir = new File(sourceDir); - assertTrue("Cannot find stdlib source: " + stdlibDir, stdlibDir.exists()); - for (String file : stdLibFiles) { - files.add(new File(stdlibDir, file).getPath()); - } - return files; - } - - @NotNull - @Override - protected List additionalKotlinFiles() { - return removeAdHocAssertions(super.additionalKotlinFiles()); - } - - @NotNull - public static List removeAdHocAssertions(List additionalKotlinFiles) { - List kotlinFiles = Lists.newArrayList(additionalKotlinFiles); - Iterator iterator = kotlinFiles.iterator(); - while (iterator.hasNext()) { - if (new File(iterator.next()).getName().equals("asserts.kt")) - iterator.remove(); - } - return kotlinFiles; - } - -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibTestToJSTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibTestToJSTest.java deleted file mode 100644 index d1cc0620173..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/StdLibTestToJSTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010-2016 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.Nullable; -import org.jetbrains.kotlin.js.test.rhino.RhinoResultChecker; - -/** - */ -public class StdLibTestToJSTest extends StdLibQUnitTestSupport { - public void testGenerateTestCase() throws Exception { - performStdLibTest(DEFAULT_ECMA_VERSIONS, - "libraries/stdlib/test", - "js/JsArrayTest.kt", - "js/MapJsTest.kt", - "collections/ListSpecificTest.kt", - "collections/IteratorsTest.kt", - "collections/CollectionBehaviors.kt", - "collections/ComparisonDSL.kt", - "testUtils.kt", - "../../../js/js.libraries/test/core/testUtils.kt", - "text/StringTest.kt", - "OrderingTest.kt", - "collections/SequenceTest.kt", - "collections/IterableTests.kt", - "collections/ArraysTest.kt", - "ranges/RangeTest.kt", - "ranges/RangeIterationTest.kt" - ); - } - - @Nullable - @Override - protected RhinoResultChecker getResultChecker() { - // don't run, it's just smoke test this tests should be run in maven build. - return null; - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsUnitTestReporter.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsUnitTestReporter.java deleted file mode 100644 index 03dece638b4..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsUnitTestReporter.java +++ /dev/null @@ -1,142 +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.utils; - -import com.intellij.util.containers.ContainerUtil; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.junit.Assert; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -public class JsUnitTestReporter { - - @NotNull - private final Map finishedTests = ContainerUtil.newHashMap(); - @NotNull - private final Map> errors = ContainerUtil.newHashMap(); - @NotNull - private final List processedTests = ContainerUtil.newArrayList(); - - @Nullable - private String currentTestName; - - //NOTE: usable from Rhino - @SuppressWarnings("UnusedDeclaration") - public void testStart(@NotNull String testName) { - assert currentTestName == null; - currentTestName = testName; - } - - //NOTE: usable from Rhino - @SuppressWarnings("UnusedDeclaration") - public void testFail(@NotNull String testName) { - assert currentTestName != null; - finishedTests.put(testName, false); - currentTestName = null; - } - - //NOTE: usable from Rhino - @SuppressWarnings("UnusedDeclaration") - public void testSuccess(@NotNull String testName) { - assert currentTestName != null; - finishedTests.put(testName, true); - currentTestName = null; - } - - //NOTE: usable from Rhino - @SuppressWarnings("UnusedDeclaration") - public void reportError(@NotNull String message) { - List errorList = errors.get(currentTestName); - if (errorList == null) { - errors.put(currentTestName, ContainerUtil.newArrayList(message)); - } - else { - errorList.add(message); - } - } - - @NotNull - private Collection getNewFinishedTests() { - List finishedTests = ContainerUtil.newArrayList(this.finishedTests.keySet()); - finishedTests.removeAll(processedTests); - return finishedTests; - } - - @NotNull - public Collection getErrors(@NotNull String testName) { - List errorList = errors.get(testName); - assert errorList != null; - assert !errorList.isEmpty(); - return errorList; - } - - @NotNull - public Boolean getResult(@NotNull String testName) { - Boolean result = finishedTests.get(testName); - assert result != null; - return result; - } - - @NotNull - public TestSuite createTestSuiteAndFlush() { - TestSuite suite = new TestSuite("!"); - Collection newFinishedTests = getNewFinishedTests(); - for (String test : newFinishedTests) { - //NOTE: well, it is a test - //noinspection JUnitTestCaseWithNoTests - suite.addTest(new TestCase(test) { - @Override - protected void runTest() throws Throwable { - Boolean result = getResult(getName()); - if (!result) { - Collection errorMessages = getErrors(getName()); - StringBuilder sb = new StringBuilder(); - for (String error : errorMessages) { - sb.append(error); - } - eraseTestInfo(getName()); - Assert.fail(sb.toString()); - } - eraseTestInfo(getName()); - } - }); - } - processedTests.addAll(newFinishedTests); - return suite; - } - - private void eraseTestInfo(@NotNull String testName) { - errors.remove(testName); - Boolean removed = finishedTests.remove(testName); - assert removed != null; - } - - public void ignoreTests(@NotNull String... testNames) { - for (String testName : testNames) { - if (getResult(testName)) { - //TODO: make test fail? - System.out.println("Test " + testName + " has passed. And we ignored it! Turn it on?"); - } - eraseTestInfo(testName); - } - } -} diff --git a/js/js.translator/testData/jsTester/jsTester.js b/js/js.translator/testData/jsTester/jsTester.js deleted file mode 100644 index 096abbd4b0a..00000000000 --- a/js/js.translator/testData/jsTester/jsTester.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010-2013 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. - */ -/*Asserter*/ - -var JsTests = (function () { - var reporter = jsTestReporter; - var failedTest = {}; - - var assert = function (isTrue, message) { - if (!isTrue) { - fail(message); - } - }; - - var fail = function (message) { - reporter.reportError(message); - throw failedTest; - }; - - var test = function (testName, testFun) { - reporter.testStart(testName); - try { - testFun(); - } - catch (fail) { - if (fail != failedTest) { - reporter.reportError("Unexpected exception " + fail + "\n" + fail.stack); - } - reporter.testFail(testName); - return; - } - reporter.testSuccess(testName); - }; - return { - test: test, - assert: assert, - fail: fail - } -})(); diff --git a/js/js.translator/testData/jsTester/jsTester.kt b/js/js.translator/testData/jsTester/jsTester.kt deleted file mode 100644 index d229e01018b..00000000000 --- a/js/js.translator/testData/jsTester/jsTester.kt +++ /dev/null @@ -1,13 +0,0 @@ -package kotlin.test - -val init = run { - _asserter = JsTestsAsserter() -} - -public class JsTestsAsserter() : Asserter { - public override fun fail(message: String?): Nothing = failWithMessage(message) -} - -public inline fun assert(value: Boolean, message: String?): Unit = js("JsTests").assert(value, message) - -private inline fun failWithMessage(message: String?): Nothing = js("JsTests").fail(message) diff --git a/libraries/stdlib/test/js/JsArrayScript.kt b/libraries/stdlib/test/js/JsArrayScript.kt index 811ee564903..42a6c25c441 100644 --- a/libraries/stdlib/test/js/JsArrayScript.kt +++ b/libraries/stdlib/test/js/JsArrayScript.kt @@ -1,4 +1,3 @@ -// this package referenced from testArrayScriptTest package test.collections.js fun testSize(): Int {