From fa1f7d988e50262875b582680cb52ebe97d6a616 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 24 Feb 2016 12:18:48 +0300 Subject: [PATCH] Get rid of CompileKotlinAgainstMultifileKotlinTestGenerated and boxMultifileClasses/ Merge tests in boxMultifileClasses/calls to one test case; copy the two resulting tests (+ change box to main) to compileKotlinAgainstKotlin --- .../callsToMultifileClassFromOtherPackage.kt | 23 ++ ...onstPropertyReferenceFromMultifileClass.kt | 0 .../calls/callFromOtherPackage.kt | 12 - .../calls/constFromOtherPackage.kt | 12 - .../calls/valFromOtherPackage.kt | 12 - .../calls/varFromOtherPackage.kt | 15 - .../callsToMultifileClassFromOtherPackage.kt | 21 ++ ...onstPropertyReferenceFromMultifileClass.kt | 27 ++ ...BlackBoxMultiFileCodegenTestGenerated.java | 350 ++++++++---------- ...actCompileKotlinAgainstInlineKotlinTest.kt | 51 +++ ...bstractCompileKotlinAgainstKotlinTest.java | 59 +-- ...mpileKotlinAgainstKotlinTestGenerated.java | 12 + ...inAgainstMultifileKotlinTestGenerated.java | 85 ----- .../kotlin/generators/tests/GenerateTests.kt | 5 - 14 files changed, 288 insertions(+), 396 deletions(-) create mode 100644 compiler/testData/codegen/boxMultiFile/callsToMultifileClassFromOtherPackage.kt rename compiler/testData/codegen/{boxMultifileClasses/reflection => boxMultiFile}/constPropertyReferenceFromMultifileClass.kt (100%) delete mode 100644 compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.kt delete mode 100644 compiler/testData/codegen/boxMultifileClasses/calls/constFromOtherPackage.kt delete mode 100644 compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.kt delete mode 100644 compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.kt create mode 100644 compiler/testData/compileKotlinAgainstKotlin/callsToMultifileClassFromOtherPackage.kt create mode 100644 compiler/testData/compileKotlinAgainstKotlin/constPropertyReferenceFromMultifileClass.kt delete mode 100644 compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstMultifileKotlinTestGenerated.java diff --git a/compiler/testData/codegen/boxMultiFile/callsToMultifileClassFromOtherPackage.kt b/compiler/testData/codegen/boxMultiFile/callsToMultifileClassFromOtherPackage.kt new file mode 100644 index 00000000000..f89f5ec7516 --- /dev/null +++ b/compiler/testData/codegen/boxMultiFile/callsToMultifileClassFromOtherPackage.kt @@ -0,0 +1,23 @@ +// FILE: 1.kt + +import a.* + +fun box(): String { + if (foo() != "OK") return "Fail function" + if (constOK != "OK") return "Fail const" + if (valOK != "OK") return "Fail val" + varOK = "OK" + if (varOK != "OK") return "Fail var" + + return "OK" +} + +// FILE: 2.kt + +@file:[JvmName("MultifileClass") JvmMultifileClass] +package a + +fun foo(): String = "OK" +const val constOK: String = "OK" +val valOK: String = "OK" +var varOK: String = "Hmmm?" diff --git a/compiler/testData/codegen/boxMultifileClasses/reflection/constPropertyReferenceFromMultifileClass.kt b/compiler/testData/codegen/boxMultiFile/constPropertyReferenceFromMultifileClass.kt similarity index 100% rename from compiler/testData/codegen/boxMultifileClasses/reflection/constPropertyReferenceFromMultifileClass.kt rename to compiler/testData/codegen/boxMultiFile/constPropertyReferenceFromMultifileClass.kt diff --git a/compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.kt b/compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.kt deleted file mode 100644 index 7234667d720..00000000000 --- a/compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.kt +++ /dev/null @@ -1,12 +0,0 @@ -// FILE: 1.kt - -import a.foo - -fun box(): String = foo() - -// FILE: 2.kt - -@file:[JvmName("MultifileClass") JvmMultifileClass] -package a - -fun foo(): String = "OK" diff --git a/compiler/testData/codegen/boxMultifileClasses/calls/constFromOtherPackage.kt b/compiler/testData/codegen/boxMultifileClasses/calls/constFromOtherPackage.kt deleted file mode 100644 index d151190244e..00000000000 --- a/compiler/testData/codegen/boxMultifileClasses/calls/constFromOtherPackage.kt +++ /dev/null @@ -1,12 +0,0 @@ -// FILE: 1.kt - -import a.OK - -fun box(): String = OK - -// FILE: 2.kt - -@file:[JvmName("MultifileClass") JvmMultifileClass] -package a - -const val OK: String = "OK" diff --git a/compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.kt b/compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.kt deleted file mode 100644 index 2498383d462..00000000000 --- a/compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.kt +++ /dev/null @@ -1,12 +0,0 @@ -// FILE: 1.kt - -import a.OK - -fun box(): String = OK - -// FILE: 2.kt - -@file:[JvmName("MultifileClass") JvmMultifileClass] -package a - -val OK: String = "OK" diff --git a/compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.kt b/compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.kt deleted file mode 100644 index 54106c76e72..00000000000 --- a/compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.kt +++ /dev/null @@ -1,15 +0,0 @@ -// FILE: 1.kt - -import a.OK - -fun box(): String { - OK = "OK" - return OK -} - -// FILE: 2.kt - -@file:[JvmName("MultifileClass") JvmMultifileClass] -package a - -var OK: String = "Hmmm?" diff --git a/compiler/testData/compileKotlinAgainstKotlin/callsToMultifileClassFromOtherPackage.kt b/compiler/testData/compileKotlinAgainstKotlin/callsToMultifileClassFromOtherPackage.kt new file mode 100644 index 00000000000..810fe413cfd --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/callsToMultifileClassFromOtherPackage.kt @@ -0,0 +1,21 @@ +// FILE: A.kt + +@file:[JvmName("MultifileClass") JvmMultifileClass] +package a + +fun foo(): String = "OK" +const val constOK: String = "OK" +val valOK: String = "OK" +var varOK: String = "Hmmm?" + +// FILE: B.kt + +import a.* + +fun main(args: Array) { + if (foo() != "OK") throw AssertionError("Fail function") + if (constOK != "OK") throw AssertionError("Fail const") + if (valOK != "OK") throw AssertionError("Fail val") + varOK = "OK" + if (varOK != "OK") throw AssertionError("Fail var") +} diff --git a/compiler/testData/compileKotlinAgainstKotlin/constPropertyReferenceFromMultifileClass.kt b/compiler/testData/compileKotlinAgainstKotlin/constPropertyReferenceFromMultifileClass.kt new file mode 100644 index 00000000000..98b1a8aa42b --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/constPropertyReferenceFromMultifileClass.kt @@ -0,0 +1,27 @@ +// FILE: A.kt + +@file:[JvmName("MultifileClass") JvmMultifileClass] +package a + +annotation class A + +@A +const val OK: String = "OK" + +// FILE: B.kt + +import a.OK + +fun main(args: Array) { + val okRef = ::OK + + // TODO: see KT-10892 +// val annotations = okRef.annotations +// val numAnnotations = annotations.size +// if (numAnnotations != 1) { +// throw AssertionError("Failed, annotations: $annotations") +// } + + val result = okRef.get() + if (result != "OK") throw AssertionError("Fail: $result") +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java index e1e51f357ce..fa99a9d9f95 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java @@ -27,215 +27,167 @@ 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/boxMultiFile") +@TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public class BlackBoxMultiFileCodegenTestGenerated extends AbstractBlackBoxCodegenTest { - @TestMetadata("compiler/testData/codegen/boxMultiFile") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BoxMultiFile extends AbstractBlackBoxCodegenTest { - @TestMetadata("accessorForProtected.kt") - public void testAccessorForProtected() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/accessorForProtected.kt"); - doTest(fileName); - } - - @TestMetadata("accessorForProtectedInvokeVirtual.kt") - public void testAccessorForProtectedInvokeVirtual() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/accessorForProtectedInvokeVirtual.kt"); - doTest(fileName); - } - - public void testAllFilesPresentInBoxMultiFile() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultiFile"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("callMultifileClassMemberFromOtherPackage.kt") - public void testCallMultifileClassMemberFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/callMultifileClassMemberFromOtherPackage.kt"); - doTest(fileName); - } - - @TestMetadata("inlineMultifileClassMemberFromOtherPackage.kt") - public void testInlineMultifileClassMemberFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/inlineMultifileClassMemberFromOtherPackage.kt"); - doTest(fileName); - } - - @TestMetadata("internalVisibility.kt") - public void testInternalVisibility() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/internalVisibility.kt"); - doTest(fileName); - } - - @TestMetadata("kt10047.kt") - public void testKt10047() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt10047.kt"); - doTest(fileName); - } - - @TestMetadata("kt1515.kt") - public void testKt1515() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1515.kt"); - doTest(fileName); - } - - @TestMetadata("kt1528.kt") - public void testKt1528() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1528.kt"); - doTest(fileName); - } - - @TestMetadata("kt1845.kt") - public void testKt1845() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1845.kt"); - doTest(fileName); - } - - @TestMetadata("kt2060.kt") - public void testKt2060() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt2060.kt"); - doTest(fileName); - } - - @TestMetadata("kt5445.kt") - public void testKt5445() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt5445.kt"); - doTest(fileName); - } - - @TestMetadata("kt5445_2.kt") - public void testKt5445_2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt5445_2.kt"); - doTest(fileName); - } - - @TestMetadata("kt9717.kt") - public void testKt9717() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9717.kt"); - doTest(fileName); - } - - @TestMetadata("kt9717DifferentPackages.kt") - public void testKt9717DifferentPackages() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9717DifferentPackages.kt"); - doTest(fileName); - } - - @TestMetadata("kt9958.kt") - public void testKt9958() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9958.kt"); - doTest(fileName); - } - - @TestMetadata("kt9958Interface.kt") - public void testKt9958Interface() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9958Interface.kt"); - doTest(fileName); - } - - @TestMetadata("mainInFiles.kt") - public void testMainInFiles() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/mainInFiles.kt"); - doTest(fileName); - } - - @TestMetadata("multifileClassPartsInitialization.kt") - public void testMultifileClassPartsInitialization() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/multifileClassPartsInitialization.kt"); - doTest(fileName); - } - - @TestMetadata("packageLocalClassNotImportedWithDefaultImport.kt") - public void testPackageLocalClassNotImportedWithDefaultImport() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/packageLocalClassNotImportedWithDefaultImport.kt"); - doTest(fileName); - } - - @TestMetadata("protectedFromLambda.kt") - public void testProtectedFromLambda() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/protectedFromLambda.kt"); - doTest(fileName); - } - - @TestMetadata("samWrappersDifferentFiles.kt") - public void testSamWrappersDifferentFiles() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/samWrappersDifferentFiles.kt"); - doTest(fileName); - } - - @TestMetadata("sameFileName.kt") - public void testSameFileName() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/sameFileName.kt"); - doTest(fileName); - } - - @TestMetadata("samePartNameDifferentFacades.kt") - public void testSamePartNameDifferentFacades() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/samePartNameDifferentFacades.kt"); - doTest(fileName); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/simple.kt"); - doTest(fileName); - } + @TestMetadata("accessorForProtected.kt") + public void testAccessorForProtected() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/accessorForProtected.kt"); + doTest(fileName); } - @TestMetadata("compiler/testData/codegen/boxMultifileClasses") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BoxMultifileClasses extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInBoxMultifileClasses() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses"), Pattern.compile("^(.+)\\.kt$"), true); - } + @TestMetadata("accessorForProtectedInvokeVirtual.kt") + public void testAccessorForProtectedInvokeVirtual() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/accessorForProtectedInvokeVirtual.kt"); + doTest(fileName); + } - @TestMetadata("compiler/testData/codegen/boxMultifileClasses/calls") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Calls extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInCalls() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses/calls"), Pattern.compile("^(.+)\\.kt$"), true); - } + public void testAllFilesPresentInBoxMultiFile() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultiFile"), Pattern.compile("^(.+)\\.kt$"), true); + } - @TestMetadata("callFromOtherPackage.kt") - public void testCallFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.kt"); - doTest(fileName); - } + @TestMetadata("callMultifileClassMemberFromOtherPackage.kt") + public void testCallMultifileClassMemberFromOtherPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/callMultifileClassMemberFromOtherPackage.kt"); + doTest(fileName); + } - @TestMetadata("constFromOtherPackage.kt") - public void testConstFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/constFromOtherPackage.kt"); - doTest(fileName); - } + @TestMetadata("callsToMultifileClassFromOtherPackage.kt") + public void testCallsToMultifileClassFromOtherPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/callsToMultifileClassFromOtherPackage.kt"); + doTest(fileName); + } - @TestMetadata("valFromOtherPackage.kt") - public void testValFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.kt"); - doTest(fileName); - } + @TestMetadata("constPropertyReferenceFromMultifileClass.kt") + public void testConstPropertyReferenceFromMultifileClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/constPropertyReferenceFromMultifileClass.kt"); + doTest(fileName); + } - @TestMetadata("varFromOtherPackage.kt") - public void testVarFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.kt"); - doTest(fileName); - } - } + @TestMetadata("inlineMultifileClassMemberFromOtherPackage.kt") + public void testInlineMultifileClassMemberFromOtherPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/inlineMultifileClassMemberFromOtherPackage.kt"); + doTest(fileName); + } - @TestMetadata("compiler/testData/codegen/boxMultifileClasses/reflection") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Reflection extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInReflection() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses/reflection"), Pattern.compile("^(.+)\\.kt$"), true); - } + @TestMetadata("internalVisibility.kt") + public void testInternalVisibility() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/internalVisibility.kt"); + doTest(fileName); + } - @TestMetadata("constPropertyReferenceFromMultifileClass.kt") - public void testConstPropertyReferenceFromMultifileClass() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/reflection/constPropertyReferenceFromMultifileClass.kt"); - doTest(fileName); - } - } + @TestMetadata("kt10047.kt") + public void testKt10047() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt10047.kt"); + doTest(fileName); + } + + @TestMetadata("kt1515.kt") + public void testKt1515() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1515.kt"); + doTest(fileName); + } + + @TestMetadata("kt1528.kt") + public void testKt1528() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1528.kt"); + doTest(fileName); + } + + @TestMetadata("kt1845.kt") + public void testKt1845() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1845.kt"); + doTest(fileName); + } + + @TestMetadata("kt2060.kt") + public void testKt2060() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt2060.kt"); + doTest(fileName); + } + + @TestMetadata("kt5445.kt") + public void testKt5445() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt5445.kt"); + doTest(fileName); + } + + @TestMetadata("kt5445_2.kt") + public void testKt5445_2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt5445_2.kt"); + doTest(fileName); + } + + @TestMetadata("kt9717.kt") + public void testKt9717() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9717.kt"); + doTest(fileName); + } + + @TestMetadata("kt9717DifferentPackages.kt") + public void testKt9717DifferentPackages() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9717DifferentPackages.kt"); + doTest(fileName); + } + + @TestMetadata("kt9958.kt") + public void testKt9958() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9958.kt"); + doTest(fileName); + } + + @TestMetadata("kt9958Interface.kt") + public void testKt9958Interface() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9958Interface.kt"); + doTest(fileName); + } + + @TestMetadata("mainInFiles.kt") + public void testMainInFiles() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/mainInFiles.kt"); + doTest(fileName); + } + + @TestMetadata("multifileClassPartsInitialization.kt") + public void testMultifileClassPartsInitialization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/multifileClassPartsInitialization.kt"); + doTest(fileName); + } + + @TestMetadata("packageLocalClassNotImportedWithDefaultImport.kt") + public void testPackageLocalClassNotImportedWithDefaultImport() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/packageLocalClassNotImportedWithDefaultImport.kt"); + doTest(fileName); + } + + @TestMetadata("protectedFromLambda.kt") + public void testProtectedFromLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/protectedFromLambda.kt"); + doTest(fileName); + } + + @TestMetadata("samWrappersDifferentFiles.kt") + public void testSamWrappersDifferentFiles() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/samWrappersDifferentFiles.kt"); + doTest(fileName); + } + + @TestMetadata("sameFileName.kt") + public void testSameFileName() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/sameFileName.kt"); + doTest(fileName); + } + + @TestMetadata("samePartNameDifferentFacades.kt") + public void testSamePartNameDifferentFacades() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/samePartNameDifferentFacades.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/simple.kt"); + doTest(fileName); } } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstInlineKotlinTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstInlineKotlinTest.kt index c41b954b659..7d0294057fb 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstInlineKotlinTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstInlineKotlinTest.kt @@ -16,10 +16,61 @@ package org.jetbrains.kotlin.jvm.compiler +import org.jetbrains.kotlin.codegen.ClassFileFactory +import org.jetbrains.kotlin.codegen.CodegenTestCase import org.jetbrains.kotlin.codegen.InlineTestUtil import org.jetbrains.kotlin.codegen.filterClassFiles +import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKotlinAgainstKotlinTest(), AbstractSMAPBaseTest { + protected fun doBoxTest(firstFileName: String): Pair { + var files: List = KotlinTestUtils.createTestFiles( + firstFileName, KotlinTestUtils.doLoadFile(File(firstFileName)), + object : KotlinTestUtils.TestFileFactory { + override fun createFile( + module: Unit?, fileName: String, text: String, directives: Map + ): CodegenTestCase.TestFile { + return CodegenTestCase.TestFile(fileName, text) + } + + override fun createModule(name: String, dependencies: List) { + throw UnsupportedOperationException() + } + }) + + // TODO: drop this (migrate codegen/box/inline/) + if (files.size == 1) { + val firstFile = files.iterator().next() + val secondFile = File(firstFileName.replace("1.kt", "2.kt")) + files = listOf(firstFile, CodegenTestCase.TestFile(secondFile.name, KotlinTestUtils.doLoadFile(secondFile))) + } + + var factory1: ClassFileFactory? = null + var factory2: ClassFileFactory? = null + try { + val fileA = files[1] + val fileB = files[0] + factory1 = compileA(fileA.name, fileA.content) + factory2 = compileB(fileB.name, fileB.content) + invokeBox(PackagePartClassUtils.getFilePartShortName(File(fileB.name).name)) + } + catch (e: Throwable) { + var result = "" + if (factory1 != null) { + result += "FIRST: \n\n" + factory1.createText() + } + if (factory2 != null) { + result += "\n\nSECOND: \n\n" + factory2.createText() + } + println(result) + throw e + } + + return Pair(factory1, factory2) + } + fun doBoxTestWithInlineCheck(firstFileName: String) { val (factory1, factory2) = doBoxTest(firstFileName) val allGeneratedFiles = factory1.asList() + factory2.asList() diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstKotlinTest.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstKotlinTest.java index 44908817047..c006fb413e4 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstKotlinTest.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstKotlinTest.java @@ -19,9 +19,7 @@ package org.jetbrains.kotlin.jvm.compiler; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Disposer; import com.intellij.util.ArrayUtil; -import kotlin.Pair; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.cli.common.modules.ModuleBuilder; import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; @@ -37,14 +35,12 @@ import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.test.ConfigurationKind; import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.TestJdkKind; -import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -80,7 +76,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest main.invoke(null, new Object[] {ArrayUtil.EMPTY_STRING_ARRAY}); } - private void invokeBox(@NotNull String className) throws Exception { + protected void invokeBox(@NotNull String className) throws Exception { Method box = createGeneratedClassLoader().loadClass(className).getMethod("box"); String result = (String) box.invoke(null); assertEquals("OK", result); @@ -95,14 +91,14 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest } @NotNull - private ClassFileFactory compileA(@NotNull String fileName, @NotNull String content) throws IOException { + protected ClassFileFactory compileA(@NotNull String fileName, @NotNull String content) throws IOException { KotlinCoreEnvironment environment = KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(getTestRootDisposable(), ConfigurationKind.ALL); return compileKotlin(fileName, content, aDir, environment, getTestRootDisposable()); } @NotNull - private ClassFileFactory compileB(@NotNull String fileName, @NotNull String content) throws IOException { + protected ClassFileFactory compileB(@NotNull String fileName, @NotNull String content) throws IOException { CompilerConfiguration configurationWithADirInClasspath = KotlinTestUtils .compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar(), aDir); @@ -128,53 +124,4 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest Disposer.dispose(disposable); return outputFiles; } - - @NotNull - protected Pair doBoxTest(@NotNull String firstFileName) throws Exception { - List files = KotlinTestUtils.createTestFiles( - firstFileName, KotlinTestUtils.doLoadFile(new File(firstFileName)), - new KotlinTestUtils.TestFileFactory() { - @Override - public TestFile createFile( - @Nullable Void module, @NotNull String fileName, @NotNull String text, @NotNull Map directives - ) { - return new TestFile(fileName, text); - } - - @Override - public Void createModule(@NotNull String name, @NotNull List dependencies) { - throw new UnsupportedOperationException(); - } - }); - - // TODO: drop this (migrate codegen/box/inline/) - if (files.size() == 1) { - TestFile firstFile = files.iterator().next(); - File secondFile = new File(firstFileName.replace("1.kt", "2.kt")); - files = Arrays.asList(firstFile, new TestFile(secondFile.getName(), KotlinTestUtils.doLoadFile(secondFile))); - } - - ClassFileFactory factory1 = null; - ClassFileFactory factory2 = null; - try { - TestFile fileA = files.get(1); - TestFile fileB = files.get(0); - factory1 = compileA(fileA.name, fileA.content); - factory2 = compileB(fileB.name, fileB.content); - invokeBox(PackagePartClassUtils.getFilePartShortName(new File(fileB.name).getName())); - } - catch (Throwable e) { - String result = ""; - if (factory1 != null) { - result += "FIRST: \n\n" + factory1.createText(); - } - if (factory2 != null) { - result += "\n\nSECOND: \n\n" + factory2.createText(); - } - System.out.println(result); - throw ExceptionUtilsKt.rethrow(e); - } - - return new Pair(factory1, factory2); - } } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java index b76aaa3e7e9..aa5b59ee4a7 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstKotlinTestGenerated.java @@ -41,6 +41,12 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl doTest(fileName); } + @TestMetadata("callsToMultifileClassFromOtherPackage.kt") + public void testCallsToMultifileClassFromOtherPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/callsToMultifileClassFromOtherPackage.kt"); + doTest(fileName); + } + @TestMetadata("classInObject.kt") public void testClassInObject() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/classInObject.kt"); @@ -59,6 +65,12 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl doTest(fileName); } + @TestMetadata("constPropertyReferenceFromMultifileClass.kt") + public void testConstPropertyReferenceFromMultifileClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/constPropertyReferenceFromMultifileClass.kt"); + doTest(fileName); + } + @TestMetadata("constructorVararg.kt") public void testConstructorVararg() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/constructorVararg.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstMultifileKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstMultifileKotlinTestGenerated.java deleted file mode 100644 index 7e0c2965a2d..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstMultifileKotlinTestGenerated.java +++ /dev/null @@ -1,85 +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.jvm.compiler; - -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/boxMultifileClasses") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class CompileKotlinAgainstMultifileKotlinTestGenerated extends AbstractCompileKotlinAgainstKotlinTest { - public void testAllFilesPresentInBoxMultifileClasses() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("compiler/testData/codegen/boxMultifileClasses/calls") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Calls extends AbstractCompileKotlinAgainstKotlinTest { - public void testAllFilesPresentInCalls() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses/calls"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("callFromOtherPackage.kt") - public void testCallFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.kt"); - doBoxTest(fileName); - } - - @TestMetadata("constFromOtherPackage.kt") - public void testConstFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/constFromOtherPackage.kt"); - doBoxTest(fileName); - } - - @TestMetadata("valFromOtherPackage.kt") - public void testValFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.kt"); - doBoxTest(fileName); - } - - @TestMetadata("varFromOtherPackage.kt") - public void testVarFromOtherPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.kt"); - doBoxTest(fileName); - } - } - - @TestMetadata("compiler/testData/codegen/boxMultifileClasses/reflection") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Reflection extends AbstractCompileKotlinAgainstKotlinTest { - public void testAllFilesPresentInReflection() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses/reflection"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("constPropertyReferenceFromMultifileClass.kt") - public void testConstPropertyReferenceFromMultifileClass() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/reflection/constPropertyReferenceFromMultifileClass.kt"); - doBoxTest(fileName); - } - } -} diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 134dd1812a7..50fd14a7b04 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -203,13 +203,8 @@ fun main(args: Array) { model("codegen/boxInline", extension = "1.kt", testMethod = "doBoxTestWithInlineCheck") } - testClass("CompileKotlinAgainstMultifileKotlinTestGenerated") { - model("codegen/boxMultifileClasses", testMethod = "doBoxTest") - } - testClass("BlackBoxMultiFileCodegenTestGenerated") { model("codegen/boxMultiFile") - model("codegen/boxMultifileClasses") } testClass("BlackBoxAgainstJavaCodegenTestGenerated") {