From 1d2da9729ef88ccdcef867d31443a21060bdebb3 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Thu, 18 Jun 2015 16:13:07 +0300 Subject: [PATCH] JS/RTTI: made cast test generated --- .../kotlin/generators/tests/GenerateTests.kt | 4 ++ .../kotlin/js/test/semantics/CastTest.java | 46 ------------- .../js/test/semantics/CastTestGenerated.java | 67 +++++++++++++++++++ .../abstractClassesForGeneratedTests.kt | 2 + 4 files changed, 73 insertions(+), 46 deletions(-) delete mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTest.java create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTestGenerated.java diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index e5742011b37..8000320dada 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1091,6 +1091,10 @@ fun main(args: Array) { testClass(javaClass()) { model("rtti/cases") } + + testClass(javaClass()) { + model("expression/cast/cases") + } } testGroup("js/js.tests/test", "compiler/testData") { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTest.java deleted file mode 100644 index 26d69eeceaf..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTest.java +++ /dev/null @@ -1,46 +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; - -/** - * A messy class where all new tests go before they are sorted which never happens. - */ -public final class CastTest extends AbstractExpressionTest { - public CastTest() { - super("cast/"); - } - - public void testCastToNullableType() throws Exception { - checkFooBoxIsOk(); - } - - public void testCastToNotNullType() throws Exception { - checkFooBoxIsOk(); - } - - public void testCastToGenericType() throws Exception { - checkFooBoxIsOk(); - } - - public void testSmartCastInExtensionFunction() throws Exception { - checkFooBoxIsOk(); - } - - public void testSmartCastInFunction() throws Exception { - checkFooBoxIsOk(); - } -} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTestGenerated.java new file mode 100644 index 00000000000..a8960e737ee --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/CastTestGenerated.java @@ -0,0 +1,67 @@ +/* + * 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/expression/cast/cases") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class CastTestGenerated extends AbstractCastTest { + public void testAllFilesPresentInCases() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/expression/cast/cases"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("castToGenericType.kt") + public void testCastToGenericType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToGenericType.kt"); + doTest(fileName); + } + + @TestMetadata("castToNotNullType.kt") + public void testCastToNotNullType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNotNullType.kt"); + doTest(fileName); + } + + @TestMetadata("castToNullableType.kt") + public void testCastToNullableType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNullableType.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastInExtensionFunction.kt") + public void testSmartCastInExtensionFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/smartCastInExtensionFunction.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastInFunction.kt") + public void testSmartCastInFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/smartCastInFunction.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 d1675b8a5dd..b68b1296fda 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 @@ -63,3 +63,5 @@ abstract class AbstractLocalClassesTest : AbstractBlackBoxTest("localClasses/") abstract class AbstractNonLocalReturnsTest : KotlinJSMultiFileTest("inline.generated/nonLocalReturns/") public abstract class AbstractRttiTest : SingleFileTranslationTest("rtti/") + +public abstract class AbstractCastTest : SingleFileTranslationTest("expression/cast/")