File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
java/ql/test/library-tests/dataflow/switchexpr Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class TestSwitchExprStmtConsistency {
2
+
3
+ static int f () { return 0 ; }
4
+
5
+ public static void test (int x ) {
6
+
7
+ // Test that getRuleExpression() and getRuleStatement() behave alike for switch expressions and statements using arrow rules.
8
+
9
+ switch (x ) {
10
+ case 1 -> f ();
11
+ case 2 -> f ();
12
+ default -> f ();
13
+ }
14
+
15
+ int result = switch (x ) {
16
+ case 1 -> f ();
17
+ case 2 -> f ();
18
+ default -> f ();
19
+ };
20
+
21
+ }
22
+
23
+ }
Original file line number Diff line number Diff line change
1
+ exprs
2
+ | TestSwitchExpr.java:9:13:9:41 | case ... | TestSwitchExpr.java:9:43:9:46 | null |
3
+ | TestSwitchExpr.java:10:13:10:22 | default | TestSwitchExpr.java:10:24:10:25 | x1 |
4
+ | TestSwitchExprStmtConsistency.java:10:7:10:15 | case ... | TestSwitchExprStmtConsistency.java:10:17:10:19 | f(...) |
5
+ | TestSwitchExprStmtConsistency.java:11:7:11:15 | case ... | TestSwitchExprStmtConsistency.java:11:17:11:19 | f(...) |
6
+ | TestSwitchExprStmtConsistency.java:12:7:12:16 | default | TestSwitchExprStmtConsistency.java:12:18:12:20 | f(...) |
7
+ | TestSwitchExprStmtConsistency.java:16:7:16:15 | case ... | TestSwitchExprStmtConsistency.java:16:17:16:19 | f(...) |
8
+ | TestSwitchExprStmtConsistency.java:17:7:17:15 | case ... | TestSwitchExprStmtConsistency.java:17:17:17:19 | f(...) |
9
+ | TestSwitchExprStmtConsistency.java:18:7:18:16 | default | TestSwitchExprStmtConsistency.java:18:18:18:20 | f(...) |
10
+ stmts
11
+ | TestSwitchExpr.java:13:13:13:28 | case ... | TestSwitchExpr.java:13:30:13:42 | { ... } |
12
+ | TestSwitchExpr.java:14:13:14:22 | default | TestSwitchExpr.java:14:24:14:52 | throw ... |
Original file line number Diff line number Diff line change
1
+ import java
2
+
3
+ query predicate exprs ( SwitchCase sc , Expr e ) { e = sc .getRuleExpression ( ) }
4
+
5
+ query predicate stmts ( SwitchCase sc , Stmt s ) { s = sc .getRuleStatement ( ) }
You can’t perform that action at this time.
0 commit comments