Skip to content

Commit 1f99607

Browse files
Java: PrintAst: Improve test
1 parent 45651cf commit 1f99607

File tree

2 files changed

+61
-22
lines changed

2 files changed

+61
-22
lines changed

java/ql/test/library-tests/printAst/A.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class A {
1818
/** Does something */
1919
@Deprecated
2020
static int doSomething(@SuppressWarnings("all") String text) {
21+
int i=0, j=1;
22+
23+
for(i=0, j=1; i<3; i++) {}
24+
25+
for(int m=0, n=1; m<3; m++) {}
26+
2127
return 0;
2228
}
2329

java/ql/test/library-tests/printAst/PrintAst.expected

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,59 @@ A.java:
3131
# 20| 1: [StringLiteral] "all"
3232
# 20| 0: [TypeAccess] String
3333
# 20| 5: [BlockStmt] stmt
34-
# 21| 0: [ReturnStmt] stmt
35-
# 21| 0: [IntegerLiteral] 0
36-
# 24| 6: [FieldDeclaration] int counter, ...;
37-
# 24| -1: [TypeAccess] int
38-
# 24| 0: [IntegerLiteral] 1
39-
# 26| 7: [BlockStmt] stmt
40-
# 27| 0: [ExprStmt] stmt
41-
# 27| 0: [AssignExpr] ...=...
42-
# 27| 0: [VarAccess] counter
43-
# 27| 1: [MethodAccess] doSomething(...)
44-
# 27| 0: [StringLiteral] "hi"
45-
# 36| 8: [Method] doSomethingElse
34+
# 21| 0: [LocalVariableDeclStmt] stmt
35+
# 21| 0: [TypeAccess] int
36+
# 21| 1: [LocalVariableDeclExpr] i
37+
# 21| 0: [IntegerLiteral] 0
38+
# 21| 2: [LocalVariableDeclExpr] j
39+
# 21| 0: [IntegerLiteral] 1
40+
# 23| 1: [ForStmt] stmt
41+
#-----| 0: (For Initializers)
42+
# 23| 1: [AssignExpr] ...=...
43+
# 23| 0: [VarAccess] i
44+
# 23| 1: [IntegerLiteral] 0
45+
# 23| 2: [AssignExpr] ...=...
46+
# 23| 0: [VarAccess] j
47+
# 23| 1: [IntegerLiteral] 1
48+
# 23| 1: [LTExpr] ... < ...
49+
# 23| 0: [VarAccess] i
50+
# 23| 1: [IntegerLiteral] 3
51+
# 23| 2: [BlockStmt] stmt
52+
# 23| 3: [PostIncExpr] ...++
53+
# 23| 0: [VarAccess] i
54+
# 25| 2: [ForStmt] stmt
55+
#-----| 0: (For Initializers)
56+
# 25| 0: [TypeAccess] int
57+
# 25| 1: [LocalVariableDeclExpr] m
58+
# 25| 0: [IntegerLiteral] 0
59+
# 25| 2: [LocalVariableDeclExpr] n
60+
# 25| 0: [IntegerLiteral] 1
61+
# 25| 1: [LTExpr] ... < ...
62+
# 25| 0: [VarAccess] m
63+
# 25| 1: [IntegerLiteral] 3
64+
# 25| 2: [BlockStmt] stmt
65+
# 25| 3: [PostIncExpr] ...++
66+
# 25| 0: [VarAccess] m
67+
# 27| 3: [ReturnStmt] stmt
68+
# 27| 0: [IntegerLiteral] 0
69+
# 30| 6: [FieldDeclaration] int counter, ...;
70+
# 30| -1: [TypeAccess] int
71+
# 30| 0: [IntegerLiteral] 1
72+
# 32| 7: [BlockStmt] stmt
73+
# 33| 0: [ExprStmt] stmt
74+
# 33| 0: [AssignExpr] ...=...
75+
# 33| 0: [VarAccess] counter
76+
# 33| 1: [MethodAccess] doSomething(...)
77+
# 33| 0: [StringLiteral] "hi"
78+
# 42| 8: [Method] doSomethingElse
4679
#-----| 1: (Annotations)
47-
# 30| 1: [Annotation] Ann1
48-
# 31| 1: [StringLiteral] "a"
49-
# 32| 2: [ArrayInit] {...}
50-
# 33| 1: [Annotation] Ann2
51-
# 34| 2: [Annotation] Ann2
52-
# 34| 1: [IntegerLiteral] 7
53-
# 36| 3: [TypeAccess] String
54-
# 36| 5: [BlockStmt] stmt
55-
# 36| 0: [ReturnStmt] stmt
56-
# 36| 0: [StringLiteral] "c"
80+
# 36| 1: [Annotation] Ann1
81+
# 37| 1: [StringLiteral] "a"
82+
# 38| 2: [ArrayInit] {...}
83+
# 39| 1: [Annotation] Ann2
84+
# 40| 2: [Annotation] Ann2
85+
# 40| 1: [IntegerLiteral] 7
86+
# 42| 3: [TypeAccess] String
87+
# 42| 5: [BlockStmt] stmt
88+
# 42| 0: [ReturnStmt] stmt
89+
# 42| 0: [StringLiteral] "c"

0 commit comments

Comments
 (0)