Skip to content

Commit f0144d6

Browse files
committed
Expose that case guard test controls its case body
1 parent da62a04 commit f0144d6

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ Test.java:
3838
# 12| 0: [StringLiteral] "d"
3939
# 13| 3: [DefaultCase] default
4040
# 13| -1: [BlockStmt] { ... }
41-
# 15| 2: [SwitchStmt] switch (...)
42-
# 15| -1: [VarAccess] s
43-
# 16| 0: [PatternCase] case T t ...
44-
# 16| -3: [EQExpr] ... == ...
45-
# 16| 0: [MethodCall] length(...)
46-
# 16| -1: [VarAccess] s
47-
# 16| 1: [IntegerLiteral] 4
48-
# 16| -1: [BlockStmt] { ... }
49-
#-----| 0: (Single Local Variable Declaration)
50-
# 16| 0: [TypeAccess] String
51-
# 16| 1: [LocalVariableDeclExpr] s2
52-
# 17| 1: [ConstCase] case ...
41+
# 15| 2: [LocalVariableDeclStmt] var ...;
42+
# 15| 0: [TypeAccess] int
43+
# 15| 1: [LocalVariableDeclExpr] len
44+
# 15| 0: [MethodCall] length(...)
45+
# 15| -1: [VarAccess] s
46+
# 16| 3: [SwitchStmt] switch (...)
47+
# 16| -1: [VarAccess] s
48+
# 17| 0: [PatternCase] case T t ...
49+
# 17| -3: [EQExpr] ... == ...
50+
# 17| 0: [VarAccess] len
51+
# 17| 1: [IntegerLiteral] 4
5352
# 17| -1: [BlockStmt] { ... }
54-
# 17| 0: [StringLiteral] "e"
55-
# 18| 2: [DefaultCase] default
53+
#-----| 0: (Single Local Variable Declaration)
54+
# 17| 0: [TypeAccess] String
55+
# 17| 1: [LocalVariableDeclExpr] s2
56+
# 18| 1: [ConstCase] case ...
5657
# 18| -1: [BlockStmt] { ... }
58+
# 18| 0: [StringLiteral] "e"
59+
# 19| 2: [DefaultCase] default
60+
# 19| -1: [BlockStmt] { ... }

java/ql/test/library-tests/guards12/Test.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ void foo(String s) {
1212
case "d" -> { }
1313
default -> { }
1414
}
15+
int len = s.length();
1516
switch (s) {
16-
case String s2 when s.length() == 4 -> { }
17+
case String s2 when len == 4 -> { }
1718
case "e" -> { }
1819
default -> { }
1920
}

java/ql/test/library-tests/guards12/guard.expected

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
| Test.java:11:7:11:17 | case ... | Test.java:9:13:9:13 | s | Test.java:11:12:11:14 | "c" | true | true | Test.java:11:7:11:17 | case ... |
77
| Test.java:12:7:12:17 | case ... | Test.java:9:13:9:13 | s | Test.java:12:12:12:14 | "d" | true | false | Test.java:13:7:13:16 | default |
88
| Test.java:12:7:12:17 | case ... | Test.java:9:13:9:13 | s | Test.java:12:12:12:14 | "d" | true | true | Test.java:12:7:12:17 | case ... |
9-
| Test.java:17:7:17:17 | case ... | Test.java:15:13:15:13 | s | Test.java:17:12:17:14 | "e" | true | false | Test.java:18:7:18:16 | default |
10-
| Test.java:17:7:17:17 | case ... | Test.java:15:13:15:13 | s | Test.java:17:12:17:14 | "e" | true | true | Test.java:17:7:17:17 | case ... |
9+
| Test.java:17:27:17:34 | ... == ... | Test.java:17:27:17:29 | len | Test.java:17:34:17:34 | 4 | true | true | Test.java:17:39:17:41 | { ... } |
10+
| Test.java:18:7:18:17 | case ... | Test.java:16:13:16:13 | s | Test.java:18:12:18:14 | "e" | true | false | Test.java:19:7:19:16 | default |
11+
| Test.java:18:7:18:17 | case ... | Test.java:16:13:16:13 | s | Test.java:18:12:18:14 | "e" | true | true | Test.java:18:7:18:17 | case ... |

0 commit comments

Comments
 (0)