From c6cf6a0df704d82992f9cdefc7327240796ed1e3 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Wed, 10 Jun 2015 19:41:35 +0300 Subject: [PATCH] JS/RTTI: use generation for rtti test --- .../kotlin/generators/tests/GenerateTests.kt | 4 + .../kotlin/js/test/semantics/RTTITest.java | 58 ------------- .../js/test/semantics/RttiTestGenerated.java | 85 +++++++++++++++++++ .../abstractClassesForGeneratedTests.kt | 2 + .../testData/rtti/cases/isSameClass.kt | 5 +- .../testData/rtti/cases/notIsOtherClass.kt | 5 +- 6 files changed, 99 insertions(+), 60 deletions(-) delete mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RTTITest.java create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RttiTestGenerated.java diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 427920ec20a..e5742011b37 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1087,6 +1087,10 @@ fun main(args: Array) { testClass() { model("reified/cases") } + + testClass(javaClass()) { + model("rtti/cases") + } } testGroup("js/js.tests/test", "compiler/testData") { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RTTITest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RTTITest.java deleted file mode 100644 index c5ecad0ff51..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RTTITest.java +++ /dev/null @@ -1,58 +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.kotlin.js.test.SingleFileTranslationTest; - -public class RTTITest extends SingleFileTranslationTest { - - public RTTITest() { - super("rtti/"); - } - - public void testRttiForClass() throws Exception { - checkFooBoxIsOk(); - } - - public void testRttiForTrait() throws Exception { - checkFooBoxIsOk(); - } - - public void testRttiForTrait2() throws Exception { - checkFooBoxIsOk(); - } - - public void testIsSameClass() throws Exception { - fooBoxTest(); - } - - public void testNotIsOtherClass() throws Exception { - fooBoxTest(); - } - - public void testCollectionClassesIsCheck() throws Exception { - checkFooBoxIsOk(); - } - - public void testStdlibEmptyListClass() throws Exception { - checkFooBoxIsOk(); - } - - public void testIsJsPrimitiveType() throws Exception { - checkFooBoxIsOk(); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RttiTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RttiTestGenerated.java new file mode 100644 index 00000000000..e61bc04fb42 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/RttiTestGenerated.java @@ -0,0 +1,85 @@ +/* + * 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.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.JetTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("js/js.translator/testData/rtti/cases") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class RttiTestGenerated extends AbstractRttiTest { + public void testAllFilesPresentInCases() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/rtti/cases"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("collectionClassesIsCheck.kt") + public void testCollectionClassesIsCheck() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt"); + doTest(fileName); + } + + @TestMetadata("isJsPrimitiveType.kt") + public void testIsJsPrimitiveType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isJsPrimitiveType.kt"); + doTest(fileName); + } + + @TestMetadata("isSameClass.kt") + public void testIsSameClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isSameClass.kt"); + doTest(fileName); + } + + @TestMetadata("notIsOtherClass.kt") + public void testNotIsOtherClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/notIsOtherClass.kt"); + doTest(fileName); + } + + @TestMetadata("rttiForClass.kt") + public void testRttiForClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForClass.kt"); + doTest(fileName); + } + + @TestMetadata("rttiForTrait.kt") + public void testRttiForTrait() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForTrait.kt"); + doTest(fileName); + } + + @TestMetadata("rttiForTrait2.kt") + public void testRttiForTrait2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForTrait2.kt"); + doTest(fileName); + } + + @TestMetadata("stdlibEmptyListClass.kt") + public void testStdlibEmptyListClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/stdlibEmptyListClass.kt"); + doTest(fileName); + } +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt index d940b47537c..d1675b8a5dd 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt @@ -61,3 +61,5 @@ abstract class AbstractSuperTest : AbstractBlackBoxTest("super/") abstract class AbstractLocalClassesTest : AbstractBlackBoxTest("localClasses/") abstract class AbstractNonLocalReturnsTest : KotlinJSMultiFileTest("inline.generated/nonLocalReturns/") + +public abstract class AbstractRttiTest : SingleFileTranslationTest("rtti/") diff --git a/js/js.translator/testData/rtti/cases/isSameClass.kt b/js/js.translator/testData/rtti/cases/isSameClass.kt index 83afceba6c2..1202d9c1734 100644 --- a/js/js.translator/testData/rtti/cases/isSameClass.kt +++ b/js/js.translator/testData/rtti/cases/isSameClass.kt @@ -4,4 +4,7 @@ class A() { } -fun box() = (A() is A) \ No newline at end of file +fun box(): String { + assertEquals(true, A() is A) + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/rtti/cases/notIsOtherClass.kt b/js/js.translator/testData/rtti/cases/notIsOtherClass.kt index 99aa12b93da..3c3a65a95b5 100644 --- a/js/js.translator/testData/rtti/cases/notIsOtherClass.kt +++ b/js/js.translator/testData/rtti/cases/notIsOtherClass.kt @@ -8,4 +8,7 @@ class B() : A() { } -fun box() = (A() !is B) \ No newline at end of file +fun box(): String { + assertEquals(true, A() !is B) + return "OK" +} \ No newline at end of file