Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f465dd5

Browse files
tamasvajksmowton
authored andcommitted
Add more annotation tests
1 parent a0cd9fe commit f465dd5

6 files changed

Lines changed: 196 additions & 102 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public @interface Annot0j {
2+
int abc() default 0;
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public @interface Annot1j {
2+
int a() default 2;
3+
4+
String b() default "ab";
5+
6+
Class c() default X.class;
7+
8+
Y d() default Y.A;
9+
10+
Y[] e() default { Y.A, Y.B };
11+
12+
Annot0j f() default @Annot0j(
13+
abc = 1
14+
);
15+
}
Lines changed: 107 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,117 @@
1+
Annot0j.java:
2+
# 0| [CompilationUnit] Annot0j
3+
# 1| 1: [Interface] Annot0j
4+
# 2| 1: [Method] abc
5+
# 2| 3: [TypeAccess] int
6+
Annot1j.java:
7+
# 0| [CompilationUnit] Annot1j
8+
# 1| 1: [Interface] Annot1j
9+
# 2| 1: [Method] a
10+
# 2| 3: [TypeAccess] int
11+
# 4| 2: [Method] b
12+
# 4| 3: [TypeAccess] String
13+
# 6| 3: [Method] c
14+
# 6| 3: [TypeAccess] Class<>
15+
# 8| 4: [Method] d
16+
# 8| 3: [TypeAccess] Y
17+
# 10| 5: [Method] e
18+
# 10| 3: [ArrayTypeAccess] ...[]
19+
# 10| 0: [TypeAccess] Y
20+
# 12| 6: [Method] f
21+
# 12| 3: [TypeAccess] Annot0j
122
def.kt:
223
# 0| [CompilationUnit] def
324
# 0| 1: [Class] DefKt
4-
# 13| 1: [Method] fn
25+
# 23| 1: [Method] fn
526
#-----| 4: (Parameters)
6-
# 13| 0: [Parameter] a
7-
# 13| 5: [BlockStmt] { ... }
8-
# 14| 0: [ExprStmt] <Expr>;
9-
# 14| 0: [MethodAccess] println(...)
10-
# 14| -1: [TypeAccess] ConsoleKt
11-
# 14| 0: [MethodAccess] abc(...)
12-
# 14| -1: [VarAccess] a
13-
# 1| 2: [Interface] SomeAnnotation
14-
# 1| 1: [Method] abc
15-
# 1| 2: [Method] y
16-
# 3| 3: [Interface] ReplaceWith
17-
# 3| 1: [Method] expression
18-
# 5| 4: [Interface] Deprecated
19-
# 6| 1: [Method] message
20-
# 7| 2: [Method] replaceWith
21-
# 9| 5: [Class] X
27+
# 23| 0: [Parameter] a
28+
# 23| 5: [BlockStmt] { ... }
29+
# 24| 0: [ExprStmt] <Expr>;
30+
# 24| 0: [MethodAccess] println(...)
31+
# 24| -1: [TypeAccess] ConsoleKt
32+
# 24| 0: [MethodAccess] a(...)
33+
# 24| -1: [VarAccess] a
34+
# 3| 2: [Interface] Annot0k
35+
# 3| 1: [Method] a
36+
# 5| 3: [Interface] Annot1k
37+
# 6| 1: [Method] a
38+
# 7| 2: [Method] b
39+
# 8| 3: [Method] c
40+
# 9| 4: [Method] d
41+
# 10| 5: [Method] e
42+
# 11| 6: [Method] f
43+
# 14| 4: [Class] X
44+
# 14| 1: [Constructor] X
45+
# 14| 5: [BlockStmt] { ... }
46+
# 14| 0: [SuperConstructorInvocationStmt] super(...)
47+
# 14| 1: [BlockStmt] { ... }
48+
# 15| 5: [Class] Y
49+
# 0| 2: [Method] values
50+
# 0| 2: [Method] valueOf
51+
#-----| 4: (Parameters)
52+
# 0| 0: [Parameter] value
53+
# 15| 4: [Constructor] Y
54+
# 15| 5: [BlockStmt] { ... }
55+
# 15| 0: [ExprStmt] <Expr>;
56+
# 15| 0: [ClassInstanceExpr] new Enum(...)
57+
# 15| -3: [TypeAccess] Unit
58+
# 15| 0: [TypeAccess] Y
59+
# 15| 1: [BlockStmt] { ... }
60+
# 19| 6: [Class] Z
2261
#-----| -3: (Annotations)
23-
# 9| 1: [Annotation] Deprecated
24-
# 0| 1: [StringLiteral] This class is deprecated
25-
# 0| 1: [Annotation] ReplaceWith
26-
# 0| 1: [StringLiteral] Y
27-
# 10| 2: [Annotation] SomeAnnotation
28-
# 0| 1: [IntegerLiteral] 5
29-
# 0| 1: [StringLiteral] a
30-
# 11| 1: [Constructor] X
31-
# 9| 5: [BlockStmt] { ... }
32-
# 9| 0: [SuperConstructorInvocationStmt] super(...)
33-
# 11| 1: [BlockStmt] { ... }
62+
# 19| 1: [Annotation] Annot0k
63+
# 0| 1: [IntegerLiteral] 1
64+
# 20| 2: [Annotation] Annot1k
65+
# 0| 1: [IntegerLiteral] 2
66+
# 0| 1: [StringLiteral] ab
67+
# 0| 1: [TypeLiteral] X.class
68+
# 0| 0: [TypeAccess] X
69+
# 0| 1: [VarAccess] B
70+
# 0| 1: [ArrayInit] {...}
71+
# 0| 1: [VarAccess] C
72+
# 0| 1: [VarAccess] A
73+
# 0| 1: [Annotation] Annot0k
74+
# 0| 1: [IntegerLiteral] 1
75+
# 21| 1: [Constructor] Z
76+
# 19| 5: [BlockStmt] { ... }
77+
# 19| 0: [SuperConstructorInvocationStmt] super(...)
78+
# 21| 1: [BlockStmt] { ... }
3479
use.java:
3580
# 0| [CompilationUnit] use
36-
# 6| 1: [Class] use
37-
#-----| -3: (Annotations)
38-
# 2| 1: [Annotation] Deprecated
39-
# 3| 1: [StringLiteral] "This class is deprecated"
40-
# 4| 2: [Annotation] ReplaceWith
41-
# 4| 1: [StringLiteral] "Y"
42-
# 5| 2: [Annotation] SomeAnnotation
43-
# 5| 2: [StringLiteral] "b"
81+
# 1| 1: [Class] use
4482
#-----| -1: (Base Types)
45-
# 6| 0: [TypeAccess] SomeAnnotation
46-
# 8| 2: [Method] abc
47-
#-----| 1: (Annotations)
48-
# 7| 1: [Annotation] Override
49-
# 8| 3: [TypeAccess] int
50-
# 8| 5: [BlockStmt] { ... }
51-
# 8| 0: [ReturnStmt] return ...
52-
# 8| 0: [IntegerLiteral] 1
53-
# 10| 3: [Method] y
83+
# 1| 0: [TypeAccess] Annot0k
84+
# 3| 2: [Method] a
5485
#-----| 1: (Annotations)
55-
# 9| 1: [Annotation] Override
56-
# 10| 3: [TypeAccess] String
57-
# 10| 5: [BlockStmt] { ... }
58-
# 10| 0: [ReturnStmt] return ...
59-
# 10| 0: [StringLiteral] ""
60-
# 13| 4: [Method] annotationType
86+
# 2| 1: [Annotation] Override
87+
# 3| 3: [TypeAccess] int
88+
# 3| 5: [BlockStmt] { ... }
89+
# 3| 0: [ReturnStmt] return ...
90+
# 3| 0: [IntegerLiteral] 1
91+
# 6| 3: [Method] annotationType
6192
#-----| 1: (Annotations)
62-
# 12| 1: [Annotation] Override
63-
# 13| 3: [TypeAccess] Class<? extends Annotation>
64-
# 13| 0: [WildcardTypeAccess] ? ...
65-
# 13| 0: [TypeAccess] Annotation
66-
# 13| 5: [BlockStmt] { ... }
67-
# 14| 0: [ReturnStmt] return ...
68-
# 14| 0: [NullLiteral] null
93+
# 5| 1: [Annotation] Override
94+
# 6| 3: [TypeAccess] Class<? extends Annotation>
95+
# 6| 0: [WildcardTypeAccess] ? ...
96+
# 6| 0: [TypeAccess] Annotation
97+
# 6| 5: [BlockStmt] { ... }
98+
# 7| 0: [ReturnStmt] return ...
99+
# 7| 0: [NullLiteral] null
100+
# 12| 4: [Class] Z
101+
#-----| -3: (Annotations)
102+
# 10| 1: [Annotation] Annot0j
103+
# 10| 1: [IntegerLiteral] 1
104+
# 11| 2: [Annotation] Annot1j
105+
# 11| 1: [IntegerLiteral] 1
106+
# 11| 2: [StringLiteral] "ac"
107+
# 11| 3: [TypeLiteral] X.class
108+
# 11| 0: [TypeAccess] X
109+
# 11| 4: [VarAccess] Y.B
110+
# 11| -1: [TypeAccess] Y
111+
# 11| 5: [ArrayInit] {...}
112+
# 11| 3: [VarAccess] Y.C
113+
# 11| -1: [TypeAccess] Y
114+
# 11| 4: [VarAccess] Y.A
115+
# 11| -1: [TypeAccess] Y
116+
# 11| 6: [Annotation] Annot0j
117+
# 11| 1: [IntegerLiteral] 2
Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
annotationDeclarations
2-
| def.kt:1:1:1:87 | SomeAnnotation | def.kt:1:53:1:66 | abc |
3-
| def.kt:1:1:1:87 | SomeAnnotation | def.kt:1:69:1:86 | y |
4-
| def.kt:3:1:3:52 | ReplaceWith | def.kt:3:30:3:51 | expression |
5-
| def.kt:5:1:7:51 | Deprecated | def.kt:6:5:6:23 | message |
6-
| def.kt:5:1:7:51 | Deprecated | def.kt:7:5:7:50 | replaceWith |
2+
| Annot0j.java:1:19:1:25 | Annot0j | Annot0j.java:2:9:2:11 | abc |
3+
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:2:9:2:9 | a |
4+
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:4:12:4:12 | b |
5+
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:6:11:6:11 | c |
6+
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:8:7:8:7 | d |
7+
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:10:9:10:9 | e |
8+
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:12:13:12:13 | f |
9+
| def.kt:3:1:3:60 | Annot0k | def.kt:3:44:3:59 | a |
10+
| def.kt:5:1:12:1 | Annot1k | def.kt:6:5:6:18 | a |
11+
| def.kt:5:1:12:1 | Annot1k | def.kt:7:5:7:24 | b |
12+
| def.kt:5:1:12:1 | Annot1k | def.kt:8:5:8:31 | c |
13+
| def.kt:5:1:12:1 | Annot1k | def.kt:9:5:9:18 | d |
14+
| def.kt:5:1:12:1 | Annot1k | def.kt:10:5:10:32 | e |
15+
| def.kt:5:1:12:1 | Annot1k | def.kt:11:5:11:31 | f |
716
annotations
8-
| def.kt:0:0:0:0 | ReplaceWith | def.kt:9:1:9:57 | Deprecated | def.kt:3:1:3:52 | ReplaceWith |
9-
| def.kt:9:1:9:57 | Deprecated | def.kt:9:1:11:7 | X | def.kt:5:1:7:51 | Deprecated |
10-
| def.kt:10:1:10:24 | SomeAnnotation | def.kt:9:1:11:7 | X | def.kt:1:1:1:87 | SomeAnnotation |
11-
| use.java:2:1:4:48 | Deprecated | use.java:6:14:6:16 | use | def.kt:5:1:7:51 | Deprecated |
12-
| use.java:4:18:4:47 | ReplaceWith | use.java:2:1:4:48 | Deprecated | def.kt:3:1:3:52 | ReplaceWith |
13-
| use.java:5:1:5:24 | SomeAnnotation | use.java:6:14:6:16 | use | def.kt:1:1:1:87 | SomeAnnotation |
17+
| def.kt:0:0:0:0 | Annot0k | def.kt:20:1:20:40 | Annot1k | def.kt:3:1:3:60 | Annot0k |
18+
| def.kt:19:1:19:17 | Annot0k | def.kt:19:1:21:10 | Z | def.kt:3:1:3:60 | Annot0k |
19+
| def.kt:20:1:20:40 | Annot1k | def.kt:19:1:21:10 | Z | def.kt:5:1:12:1 | Annot1k |
20+
| use.java:10:5:10:21 | Annot0j | use.java:12:18:12:18 | Z | Annot0j.java:1:19:1:25 | Annot0j |
21+
| use.java:11:5:11:90 | Annot1j | use.java:12:18:12:18 | Z | Annot1j.java:1:19:1:25 | Annot1j |
22+
| use.java:11:73:11:89 | Annot0j | use.java:11:5:11:90 | Annot1j | Annot0j.java:1:19:1:25 | Annot0j |
1423
annotationValues
15-
| def.kt:0:0:0:0 | ReplaceWith | def.kt:0:0:0:0 | Y |
16-
| def.kt:9:1:9:57 | Deprecated | def.kt:0:0:0:0 | ReplaceWith |
17-
| def.kt:9:1:9:57 | Deprecated | def.kt:0:0:0:0 | This class is deprecated |
18-
| def.kt:10:1:10:24 | SomeAnnotation | def.kt:0:0:0:0 | 5 |
19-
| def.kt:10:1:10:24 | SomeAnnotation | def.kt:0:0:0:0 | a |
20-
| use.java:2:1:4:48 | Deprecated | use.java:3:14:3:39 | "This class is deprecated" |
21-
| use.java:2:1:4:48 | Deprecated | use.java:4:18:4:47 | ReplaceWith |
22-
| use.java:4:18:4:47 | ReplaceWith | use.java:4:44:4:46 | "Y" |
23-
| use.java:5:1:5:24 | SomeAnnotation | use.java:5:21:5:23 | "b" |
24+
| def.kt:0:0:0:0 | Annot0k | def.kt:0:0:0:0 | 1 |
25+
| def.kt:19:1:19:17 | Annot0k | def.kt:0:0:0:0 | 1 |
26+
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | 2 |
27+
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | Annot0k |
28+
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | B |
29+
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | X.class |
30+
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | ab |
31+
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | {...} |
32+
| use.java:10:5:10:21 | Annot0j | use.java:10:20:10:20 | 1 |
33+
| use.java:11:5:11:90 | Annot1j | use.java:11:18:11:18 | 1 |
34+
| use.java:11:5:11:90 | Annot1j | use.java:11:25:11:28 | "ac" |
35+
| use.java:11:5:11:90 | Annot1j | use.java:11:35:11:41 | X.class |
36+
| use.java:11:5:11:90 | Annot1j | use.java:11:48:11:50 | Y.B |
37+
| use.java:11:5:11:90 | Annot1j | use.java:11:57:11:66 | {...} |
38+
| use.java:11:5:11:90 | Annot1j | use.java:11:73:11:89 | Annot0j |
39+
| use.java:11:73:11:89 | Annot0j | use.java:11:88:11:88 | 2 |
2440
#select
41+
| Annot0j.java:1:19:1:25 | Annot0j | Interface |
42+
| Annot1j.java:1:19:1:25 | Annot1j | Interface |
2543
| def.kt:0:0:0:0 | DefKt | Class |
26-
| def.kt:1:1:1:87 | SomeAnnotation | Interface |
27-
| def.kt:3:1:3:52 | ReplaceWith | Interface |
28-
| def.kt:5:1:7:51 | Deprecated | Interface |
29-
| def.kt:9:1:11:7 | X | Class |
30-
| use.java:6:14:6:16 | use | Class |
44+
| def.kt:3:1:3:60 | Annot0k | Interface |
45+
| def.kt:5:1:12:1 | Annot1k | Interface |
46+
| def.kt:14:1:14:10 | X | Class |
47+
| def.kt:15:1:17:1 | Y | Class |
48+
| def.kt:19:1:21:10 | Z | Class |
49+
| use.java:1:14:1:16 | use | Class |
50+
| use.java:12:18:12:18 | Z | Class |
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
annotation class SomeAnnotation(@get:JvmName("abc") val x: Int = 5, val y: String = "")
1+
import kotlin.reflect.KClass
22

3-
annotation class ReplaceWith(val expression: String)
3+
annotation class Annot0k(@get:JvmName("a") val abc: Int = 0)
44

5-
annotation class Deprecated(
6-
val message: String,
7-
val replaceWith: ReplaceWith = ReplaceWith(""))
5+
annotation class Annot1k(
6+
val a: Int = 2,
7+
val b: String = "ab",
8+
val c: KClass<*> = X::class,
9+
val d: Y = Y.A,
10+
val e: Array<Y> = [Y.A, Y.B],
11+
val f: Annot0k = Annot0k(1)
12+
)
813

9-
@Deprecated("This class is deprecated", ReplaceWith("Y"))
10-
@SomeAnnotation(y = "a")
11-
class X
14+
class X {}
15+
enum class Y {
16+
A,B,C
17+
}
18+
19+
@Annot0k(abc = 1)
20+
@Annot1k(d = Y.B, e = arrayOf(Y.C, Y.A))
21+
class Z {}
1222

13-
fun fn(a: SomeAnnotation) {
14-
println(a.x)
23+
fun fn(a: Annot0k) {
24+
println(a.abc)
1525
}
1626

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
2-
@Deprecated(
3-
message = "This class is deprecated",
4-
replaceWith = @ReplaceWith(expression = "Y"))
5-
@SomeAnnotation(y = "b")
6-
public class use implements SomeAnnotation {
7-
@Override
8-
public int abc() { return 1; }
1+
public class use implements Annot0k {
92
@Override
10-
public String y() { return ""; }
3+
public int a() { return 1; }
114

125
@Override
136
public Class<? extends java.lang.annotation.Annotation> annotationType() {
147
return null;
158
}
9+
10+
@Annot0j(abc = 1)
11+
@Annot1j(a = 1, b = "ac", c = X.class, d = Y.B, e = {Y.C, Y.A}, f = @Annot0j(abc = 2))
12+
public class Z { }
1613
}

0 commit comments

Comments
 (0)