Make annotation collector tests more thorough

This commit is contained in:
Alexey Tsvetkov
2016-04-15 00:25:56 +03:00
parent e84ae5117d
commit 12531c4a90
16 changed files with 166 additions and 17 deletions
@@ -0,0 +1,18 @@
p org.test 0
d 0/Ann1
a java.lang.annotation.Inherited 0
c 0 0/Ann1
a java.lang.annotation.Retention 1
c 1 0/Ann1
d 0/Ann2
c 0 0/Ann2
c 1 0/Ann2
d 0/A
a org.test.Ann1 2
c 2 0/A
d 0/A$DefaultImpls
d 0/B
a org.test.Ann2 3
c 3 0/B
d 0/C
d 0/D
@@ -0,0 +1,19 @@
package org.test
import java.lang.annotation.Inherited
@Inherited
annotation class Ann1
@Inherited
annotation class Ann2
@Ann1
interface A
@Ann2
open class B : A
open class C : B()
class D : C()
@@ -1,4 +1,11 @@
p org.test 0
d 0/SomeInterface
d 0/SomeInterface$DefaultImpls
d 0/SomeClass
d 0/Ann
a java.lang.annotation.Inherited 0
c 0 0/Ann
a java.lang.annotation.Retention 1
c 1 0/Ann
d 0/A
a org.test.Ann 2
c 2 0/A
d 0/A$DefaultImpls
d 0/B
@@ -1,5 +1,11 @@
package org.test
public interface SomeInterface
import java.lang.annotation.Inherited
public class SomeClass
@Inherited
annotation class Ann
@Ann
interface A
class B : A
@@ -0,0 +1,4 @@
a java.lang.Deprecated 0
p org.test 0
m 0 0/Class$method$1 invoke
m 0 0/LocalFunctionsKt$function$1 invoke
@@ -0,0 +1,11 @@
package org.test
class Class {
fun method() {
@java.lang.Deprecated fun localFunctionInsideMethod() {}
}
}
fun function() {
@java.lang.Deprecated fun localFunctionInsideFunction() {}
}
@@ -1,3 +1,8 @@
a java.lang.Deprecated 0
a java.lang.annotation.Retention 0
p org.test 0
m 0 0/SomeClass$annotatedFunction$1 invoke
c 0 0/Ann
a org.test.Ann 1
m 1 0/Parent overridenWithoutAnnotation
m 1 0/Parent notOverriden
m 1 0/Child overridenWithAnnotation
m 1 0/Child childMethod
@@ -1,13 +1,25 @@
package org.test
public class SomeClass {
annotation class Ann
public fun annotatedFunction() {
open class Parent {
@Ann
open fun overridenWithoutAnnotation() {}
@java.lang.Deprecated fun localFunction() {
open fun overridenWithAnnotation() {}
}
@Ann
fun notOverriden() {}
}
open fun notAnnotated() {}
}
class Child : Parent() {
override fun overridenWithoutAnnotation() {}
@Ann
override fun overridenWithAnnotation() {}
@Ann
fun childMethod() {}
}
@@ -0,0 +1,3 @@
package org.test
annotation class Ann
@@ -0,0 +1,10 @@
a org.test.Ann 0
p org.test 0
m 0 0/TestFacade__PartAKt funA
m 0 0/TestFacade__PartAKt valA$annotations
m 0 0/TestFacade__PartBKt funB
m 0 0/TestFacade__PartBKt valB$annotations
m 0 0/TestFacade funA
m 0 0/TestFacade funB
a java.lang.annotation.Retention 1
c 1 0/Ann
@@ -0,0 +1,10 @@
@file:JvmMultifileClass
@file:JvmName("TestFacade")
package org.test
@Ann
fun funA() {}
@Ann
val valA = 4
@@ -0,0 +1,10 @@
@file:JvmMultifileClass
@file:JvmName("TestFacade")
package org.test
@Ann
fun funB() {}
@Ann
val valB = 4
@@ -0,0 +1,6 @@
a java.lang.annotation.Retention 0
p org.test 0
c 0 0/Ann
a org.test.Ann 1
m 1 0/TopLevelAnnotatedKt someAnnotatedFunction
m 1 0/TopLevelAnnotatedKt someAnnotatedValue$annotations
@@ -0,0 +1,9 @@
package org.test
annotation class Ann
@Ann
fun someAnnotatedFunction() {}
@Ann
val someAnnotatedValue = 4
@@ -31,11 +31,12 @@ import java.io.StringWriter
abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() {
override fun doTest(path: String) {
val testName = getTestName(true)
val fileName = path + testName + ".kt"
val ktFiles = File(path).listFiles { file -> file.isFile && file.extension.toLowerCase() == "kt" }
val testFiles = ktFiles.map { TestFile(it.name, it.readText()) }
val supportInheritedAnnotations = testName.startsWith("inherited")
val collectorExtension = createTestEnvironment(supportInheritedAnnotations)
loadFileByFullPath(fileName)
loadMultiFiles(testFiles)
CodegenTestUtil.generateFiles(myEnvironment, myFiles)
val actualAnnotations = KotlinTestUtils.replaceHashWithStar(collectorExtension.stringWriter.toString())
@@ -77,9 +77,9 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce
doTest(fileName);
}
@TestMetadata("inheritedSimple")
public void testInheritedSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedSimple/");
@TestMetadata("inheritedComplex")
public void testInheritedComplex() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedComplex/");
doTest(fileName);
}
@@ -95,12 +95,24 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce
doTest(fileName);
}
@TestMetadata("localFunctions")
public void testLocalFunctions() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/localFunctions/");
doTest(fileName);
}
@TestMetadata("methodAnnotations")
public void testMethodAnnotations() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/methodAnnotations/");
doTest(fileName);
}
@TestMetadata("multiFileTopLevelAnnotated")
public void testMultiFileTopLevelAnnotated() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/");
doTest(fileName);
}
@TestMetadata("nestedClasses")
public void testNestedClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/nestedClasses/");
@@ -112,4 +124,10 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/platformStatic/");
doTest(fileName);
}
@TestMetadata("topLevelAnnotated")
public void testTopLevelAnnotated() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/");
doTest(fileName);
}
}