diff --git a/compiler/testData/codegen/java9/box/concatDynamic.kt b/compiler/testData/codegen/java9/box/concatDynamic.kt index 2c684da3f4e..37753eb20aa 100644 --- a/compiler/testData/codegen/java9/box/concatDynamic.kt +++ b/compiler/testData/codegen/java9/box/concatDynamic.kt @@ -7,8 +7,4 @@ fun box(): String { val s = a + "1" + "2" + 3 + 4L + b + 5.0 + 6F + '7' + true + false + 3147483647u + p return if (s != "_1234_5.06.07truefalse31474836473147483648") "fail $s" else "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } -} +} \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/concatDynamic200.kt b/compiler/testData/codegen/java9/box/concatDynamic200.kt index 8748f1603c1..67340759357 100644 --- a/compiler/testData/codegen/java9/box/concatDynamic200.kt +++ b/compiler/testData/codegen/java9/box/concatDynamic200.kt @@ -15,8 +15,4 @@ fun box(): String { return if (result.length != 200) "fail: ${result.length}" else "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } -} +} \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/concatDynamic201.kt b/compiler/testData/codegen/java9/box/concatDynamic201.kt index de3808a0035..06207a053d7 100644 --- a/compiler/testData/codegen/java9/box/concatDynamic201.kt +++ b/compiler/testData/codegen/java9/box/concatDynamic201.kt @@ -16,8 +16,4 @@ fun box(): String { return if (result.length != 201) "fail: ${result.length}" else "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } -} +} \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/concatDynamicIndy200.kt b/compiler/testData/codegen/java9/box/concatDynamicIndy200.kt index 7aef336f88f..0d9284a5604 100644 --- a/compiler/testData/codegen/java9/box/concatDynamicIndy200.kt +++ b/compiler/testData/codegen/java9/box/concatDynamicIndy200.kt @@ -15,8 +15,4 @@ fun box(): String { return if (result.length != 200) "fail: ${result.length}" else "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } -} +} \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/concatDynamicIndy201.kt b/compiler/testData/codegen/java9/box/concatDynamicIndy201.kt index a76dfaa790b..8d28a89f659 100644 --- a/compiler/testData/codegen/java9/box/concatDynamicIndy201.kt +++ b/compiler/testData/codegen/java9/box/concatDynamicIndy201.kt @@ -16,8 +16,4 @@ fun box(): String { return if (result.length != 201) "fail: ${result.length}" else "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } -} +} \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/concatDynamicInlineClasses.kt b/compiler/testData/codegen/java9/box/concatDynamicInlineClasses.kt index 39933ea1bd0..a13b01c4666 100644 --- a/compiler/testData/codegen/java9/box/concatDynamicInlineClasses.kt +++ b/compiler/testData/codegen/java9/box/concatDynamicInlineClasses.kt @@ -24,8 +24,4 @@ fun box(): String { if (test5 != "2nullnull") return "fail 5: $test5" return "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } } \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/concatDynamicWithInline.kt b/compiler/testData/codegen/java9/box/concatDynamicWithInline.kt index b430a20d795..958aa279f7a 100644 --- a/compiler/testData/codegen/java9/box/concatDynamicWithInline.kt +++ b/compiler/testData/codegen/java9/box/concatDynamicWithInline.kt @@ -18,8 +18,4 @@ fun box(): String { val result2 = test { it + "_" } return if (result2 != "12_3456_789_10") "fail 2: $result2" else "OK" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } } \ No newline at end of file diff --git a/compiler/testData/codegen/java9/box/varHandle.kt b/compiler/testData/codegen/java9/box/varHandle.kt index f1511259d47..bdbf3eab67e 100644 --- a/compiler/testData/codegen/java9/box/varHandle.kt +++ b/compiler/testData/codegen/java9/box/varHandle.kt @@ -31,8 +31,4 @@ fun box(): String { } return if (handle.getVolatile(array, index) == newValue) "OK" else "Fail" -} - -fun main() { - box().let { if (it != "OK") throw AssertionError(it) } -} +} \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt new file mode 100644 index 00000000000..74ed94364cd --- /dev/null +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractJdk9BlackBoxCodegenTest.kt @@ -0,0 +1,16 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.codegen + +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.TestJdkKind +import java.io.File + +abstract class AbstractJdk9BlackBoxCodegenTest : AbstractCustomJDKBlackBoxCodegenTest() { + override fun getTestJdkKind(): TestJdkKind = TestJdkKind.FULL_JDK_9 + override fun getJdkHome(): File = KotlinTestUtils.getJdk9Home() + override fun getPrefix(): String = "java9/box" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt deleted file mode 100644 index d4fd2582610..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.codegen - -import org.jetbrains.kotlin.cli.common.output.writeAll -import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime -import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils -import org.jetbrains.kotlin.test.ConfigurationKind -import org.jetbrains.kotlin.test.KotlinTestUtils -import org.jetbrains.kotlin.test.TestJdkKind -import java.io.File -import java.util.concurrent.TimeUnit - -// TODO: merge into main codegen box tests somehow -class Java9CodegenTest : AbstractBlackBoxCodegenTest() { - override fun setUp() { - super.setUp() - val fileName = KotlinTestUtils.getTestDataPathBase() + "/codegen/" + prefix + "/" + getTestName(true) + ".kt" - val testFile = TestFile(fileName, File(fileName).readText()) - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.NO_KOTLIN_REFLECT, listOf(testFile), TestJdkKind.FULL_JDK_9) - } - - override fun getPrefix(): String = "java9/box" - - override fun blackBox(reportFailures: Boolean) { - val tmpdir = KotlinTestUtils.tmpDirForTest(this) - generateClassesInFile().writeAll(tmpdir, null) - - val jdk9Home = KotlinTestUtils.getJdk9Home() - val javaExe = File(jdk9Home, "bin/java.exe").takeIf(File::exists) - ?: File(jdk9Home, "bin/java").takeIf(File::exists) - ?: error("Can't find 'java' executable in $jdk9Home") - - val command = arrayOf( - javaExe.absolutePath, - "-ea", - "-classpath", - listOf(tmpdir, ForTestCompileRuntime.runtimeJarForTests()).joinToString(File.pathSeparator, transform = File::getAbsolutePath), - PackagePartClassUtils.getFilePartShortName(getTestName(false)) - ) - - val process = ProcessBuilder(*command).inheritIO().start() - process.waitFor(1, TimeUnit.MINUTES) - assertEquals(0, process.exitValue()) - } - - fun testVarHandle() { - loadFile() - blackBox(true) - } - - fun testConcatDynamic() { - loadFile() - blackBox(true) - } - - fun testConcatDynamic200() { - loadFile() - blackBox(true) - } - - fun testConcatDynamic201() { - loadFile() - blackBox(true) - } - - fun testConcatDynamicIndy200() { - loadFile() - blackBox(true) - } - - fun testConcatDynamicIndy201() { - loadFile() - blackBox(true) - } - - fun testConcatDynamicWithInline() { - loadFile() - blackBox(true) - } - - fun testConcatDynamicInlineClasses() { - loadFile() - blackBox(true) - } -} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java new file mode 100644 index 00000000000..59349e24c79 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/codegen/Jdk9BlackBoxCodegenTestGenerated.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.codegen; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +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("compiler/testData/codegen/java9/box") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class Jdk9BlackBoxCodegenTestGenerated extends AbstractJdk9BlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInBox() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/java9/box"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("concatDynamic.kt") + public void testConcatDynamic() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamic.kt"); + } + + @TestMetadata("concatDynamic200.kt") + public void testConcatDynamic200() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamic200.kt"); + } + + @TestMetadata("concatDynamic201.kt") + public void testConcatDynamic201() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamic201.kt"); + } + + @TestMetadata("concatDynamicIndy200.kt") + public void testConcatDynamicIndy200() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicIndy200.kt"); + } + + @TestMetadata("concatDynamicIndy201.kt") + public void testConcatDynamicIndy201() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicIndy201.kt"); + } + + @TestMetadata("concatDynamicInlineClasses.kt") + public void testConcatDynamicInlineClasses() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicInlineClasses.kt"); + } + + @TestMetadata("concatDynamicWithInline.kt") + public void testConcatDynamicWithInline() throws Exception { + runTest("compiler/testData/codegen/java9/box/concatDynamicWithInline.kt"); + } + + @TestMetadata("varHandle.kt") + public void testVarHandle() throws Exception { + runTest("compiler/testData/codegen/java9/box/varHandle.kt"); + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index 55105acc4af..f06e2aba8f4 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -215,6 +215,10 @@ fun main(args: Array) { model("codegen/java15/box") } + testClass { + model("codegen/java9/box") + } + testClass { model("codegen/script", extension = "kts") }