Add tests for inherited annotations (class declarations)
This commit is contained in:
+8
-5
@@ -35,12 +35,15 @@ import org.junit.Assert.*
|
||||
public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val fileName = path + getTestName(true) + ".kt"
|
||||
val collectorExtension = createTestEnvironment()
|
||||
val testName = getTestName(true)
|
||||
val fileName = path + testName + ".kt"
|
||||
val supportInheritedAnnotations = testName.startsWith("inherited")
|
||||
|
||||
val collectorExtension = createTestEnvironment(supportInheritedAnnotations)
|
||||
loadFileByFullPath(fileName)
|
||||
CodegenTestUtil.generateFiles(myEnvironment, myFiles)
|
||||
|
||||
val actualAnnotations = collectorExtension.stringWriter.toString()
|
||||
val actualAnnotations = JetTestUtils.replaceHashWithStar(collectorExtension.stringWriter.toString())
|
||||
val expectedAnnotationsFile = File(path + "annotations.txt")
|
||||
|
||||
JetTestUtils.assertEqualsToFile(expectedAnnotationsFile, actualAnnotations)
|
||||
@@ -50,12 +53,12 @@ public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
|
||||
return "plugins/annotation-collector/testData/codegen/"
|
||||
}
|
||||
|
||||
fun createTestEnvironment(): AnnotationCollectorExtensionForTests {
|
||||
fun createTestEnvironment(supportInheritedAnnotations: Boolean): AnnotationCollectorExtensionForTests {
|
||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
||||
val environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val project = environment.project
|
||||
|
||||
val collectorExtension = AnnotationCollectorExtensionForTests(false)
|
||||
val collectorExtension = AnnotationCollectorExtensionForTests(supportInheritedAnnotations)
|
||||
ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension)
|
||||
|
||||
myEnvironment = environment
|
||||
|
||||
+12
@@ -77,6 +77,18 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedSimple")
|
||||
public void testInheritedSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedSimple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedTopLevel")
|
||||
public void testInheritedTopLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localClasses")
|
||||
public void testLocalClasses() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/localClasses/");
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
p org.test 0
|
||||
d 0/SomeInterface
|
||||
d 0/SomeInterface$$TImpl
|
||||
d 0/SomeClass
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.test
|
||||
|
||||
public interface SomeInterface
|
||||
|
||||
public class SomeClass
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
p org.test 0
|
||||
d 0/TestPackage$inheritedTopLevel$*
|
||||
a org.jetbrains.annotations.NotNull 0
|
||||
m 0 0/TestPackage$inheritedTopLevel$* getTopLevelProperty
|
||||
d 0/TestPackage
|
||||
m 0 0/TestPackage getTopLevelProperty
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package org.test
|
||||
|
||||
fun topLevelFunction() {
|
||||
|
||||
}
|
||||
|
||||
val topLevelProperty: String
|
||||
get() = "text"
|
||||
Reference in New Issue
Block a user