From cdcde634e886345143c77d9d05de9b8fff7ddf9c Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 15 Apr 2021 11:30:10 +0300 Subject: [PATCH] Add basic Java 9 module tests --- .../java9Tests/binaryModuleInfoAnnotation.kt | 18 ++++++ .../java9Tests/binaryModuleInfoAnnotation.txt | 11 ++++ .../java9Tests/sourceModuleInfoAnnotation.kt | 19 ++++++ .../java9Tests/sourceModuleInfoAnnotation.txt | 11 ++++ ...sNoAnnotationInClasspathTestGenerated.java | 60 ++++++------------- ...spathWithPsiClassReadingTestGenerated.java | 60 ++++++------------- .../ForeignAnnotationsTestGenerated.java | 60 ++++++------------- .../generators/GenerateJUnit5CompilerTests.kt | 3 + 8 files changed, 116 insertions(+), 126 deletions(-) create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt new file mode 100644 index 00000000000..6d05a605501 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt @@ -0,0 +1,18 @@ +// FILE: module-info.java +// INCLUDE_JAVA_AS_BINARY +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; +} + +// FILE: Test.java +public class Test { + void foo(Integer x) {} +} + +// FILE: main.kt +fun main(x: Test) { + x.foo(1) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt new file mode 100644 index 00000000000..fdf763e20ed --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.txt @@ -0,0 +1,11 @@ +package + +public fun main(/*0*/ x: Test): kotlin.Unit + +public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt new file mode 100644 index 00000000000..b520047a76d --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt @@ -0,0 +1,19 @@ +// ALLOW_KOTLIN_PACKAGE + +// FILE: module-info.java +import org.jspecify.nullness.NullMarked; + +@NullMarked +module sandbox { + requires java9_annotations; +} + +// FILE: Test.java +public class Test { + void foo(Integer x) {} +} + +// FILE: main.kt +fun main(x: Test) { + x.foo(1) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt new file mode 100644 index 00000000000..fdf763e20ed --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.txt @@ -0,0 +1,11 @@ +package + +public fun main(/*0*/ x: Test): kotlin.Unit + +public open class Test { + public constructor Test() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun foo(/*0*/ x: kotlin.Int!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java index 9af21a594c3..61f802062e3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java @@ -1059,51 +1059,27 @@ public class ForeignAnnotationsNoAnnotationInClasspathTestGenerated extends Abst } } } + } - @Nested - @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava") - @TestDataPath("$PROJECT_ROOT") - public class TypeEnhancementOnCompiledJava { - @Test - public void testAllFilesPresentInTypeEnhancementOnCompiledJava() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava"), Pattern.compile("^(.+)\\.kt$"), null, true); - } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests") + @TestDataPath("$PROJECT_ROOT") + public class Java9Tests { + @Test + public void testAllFilesPresentInJava9Tests() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests"), Pattern.compile("^(.+)\\.kt$"), null, true); + } - @Test - @TestMetadata("ClassTypeParameterBound.kt") - public void testClassTypeParameterBound() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBound.kt"); - } + @Test + @TestMetadata("binaryModuleInfoAnnotation.kt") + public void testBinaryModuleInfoAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt"); + } - @Test - @TestMetadata("ClassTypeParameterBoundWithWarnings.kt") - public void testClassTypeParameterBoundWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt"); - } - - @Test - @TestMetadata("ReturnType.kt") - public void testReturnType() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ReturnType.kt"); - } - - @Test - @TestMetadata("ReturnTypeWithWarnings.kt") - public void testReturnTypeWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ReturnTypeWithWarnings.kt"); - } - - @Test - @TestMetadata("ValueParameter.kt") - public void testValueParameter() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ValueParameter.kt"); - } - - @Test - @TestMetadata("ValueParameterWithWarnings.kt") - public void testValueParameterWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ValueParameterWithWarnings.kt"); - } + @Test + @TestMetadata("sourceModuleInfoAnnotation.kt") + public void testSourceModuleInfoAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt"); } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathWithPsiClassReadingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathWithPsiClassReadingTestGenerated.java index 41aa9cfba34..d81d95e39c8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathWithPsiClassReadingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsNoAnnotationInClasspathWithPsiClassReadingTestGenerated.java @@ -1059,51 +1059,27 @@ public class ForeignAnnotationsNoAnnotationInClasspathWithPsiClassReadingTestGen } } } + } - @Nested - @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava") - @TestDataPath("$PROJECT_ROOT") - public class TypeEnhancementOnCompiledJava { - @Test - public void testAllFilesPresentInTypeEnhancementOnCompiledJava() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava"), Pattern.compile("^(.+)\\.kt$"), null, true); - } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests") + @TestDataPath("$PROJECT_ROOT") + public class Java9Tests { + @Test + public void testAllFilesPresentInJava9Tests() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests"), Pattern.compile("^(.+)\\.kt$"), null, true); + } - @Test - @TestMetadata("ClassTypeParameterBound.kt") - public void testClassTypeParameterBound() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBound.kt"); - } + @Test + @TestMetadata("binaryModuleInfoAnnotation.kt") + public void testBinaryModuleInfoAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt"); + } - @Test - @TestMetadata("ClassTypeParameterBoundWithWarnings.kt") - public void testClassTypeParameterBoundWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt"); - } - - @Test - @TestMetadata("ReturnType.kt") - public void testReturnType() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ReturnType.kt"); - } - - @Test - @TestMetadata("ReturnTypeWithWarnings.kt") - public void testReturnTypeWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ReturnTypeWithWarnings.kt"); - } - - @Test - @TestMetadata("ValueParameter.kt") - public void testValueParameter() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ValueParameter.kt"); - } - - @Test - @TestMetadata("ValueParameterWithWarnings.kt") - public void testValueParameterWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ValueParameterWithWarnings.kt"); - } + @Test + @TestMetadata("sourceModuleInfoAnnotation.kt") + public void testSourceModuleInfoAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt"); } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsTestGenerated.java index f24c95a5ca6..c287bcdb9a6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsTestGenerated.java @@ -1059,51 +1059,27 @@ public class ForeignAnnotationsTestGenerated extends AbstractForeignAnnotationsT } } } + } - @Nested - @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava") - @TestDataPath("$PROJECT_ROOT") - public class TypeEnhancementOnCompiledJava { - @Test - public void testAllFilesPresentInTypeEnhancementOnCompiledJava() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava"), Pattern.compile("^(.+)\\.kt$"), null, true); - } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests") + @TestDataPath("$PROJECT_ROOT") + public class Java9Tests { + @Test + public void testAllFilesPresentInJava9Tests() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests"), Pattern.compile("^(.+)\\.kt$"), null, true); + } - @Test - @TestMetadata("ClassTypeParameterBound.kt") - public void testClassTypeParameterBound() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBound.kt"); - } + @Test + @TestMetadata("binaryModuleInfoAnnotation.kt") + public void testBinaryModuleInfoAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/binaryModuleInfoAnnotation.kt"); + } - @Test - @TestMetadata("ClassTypeParameterBoundWithWarnings.kt") - public void testClassTypeParameterBoundWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt"); - } - - @Test - @TestMetadata("ReturnType.kt") - public void testReturnType() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ReturnType.kt"); - } - - @Test - @TestMetadata("ReturnTypeWithWarnings.kt") - public void testReturnTypeWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ReturnTypeWithWarnings.kt"); - } - - @Test - @TestMetadata("ValueParameter.kt") - public void testValueParameter() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ValueParameter.kt"); - } - - @Test - @TestMetadata("ValueParameterWithWarnings.kt") - public void testValueParameterWithWarnings() throws Exception { - runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/typeEnhancementOnCompiledJava/ValueParameterWithWarnings.kt"); - } + @Test + @TestMetadata("sourceModuleInfoAnnotation.kt") + public void testSourceModuleInfoAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java9Tests/sourceModuleInfoAnnotation.kt"); } } } diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt index b09de4de2e9..6e51b37a12f 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt @@ -50,16 +50,19 @@ fun generateJUnit5CompilerTests(args: Array) { testClass { model("diagnostics/foreignAnnotationsTests/tests") model("diagnostics/foreignAnnotationsTests/java8Tests") + model("diagnostics/foreignAnnotationsTests/java9Tests") } testClass { model("diagnostics/foreignAnnotationsTests/tests") model("diagnostics/foreignAnnotationsTests/java8Tests") + model("diagnostics/foreignAnnotationsTests/java9Tests") } testClass { model("diagnostics/foreignAnnotationsTests/tests") model("diagnostics/foreignAnnotationsTests/java8Tests") + model("diagnostics/foreignAnnotationsTests/java9Tests") } testClass {