mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Add test
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
public class TestSwitchExprStmtConsistency {
|
||||
|
||||
static int f() { return 0; }
|
||||
|
||||
public static void test(int x) {
|
||||
|
||||
// Test that getRuleExpression() and getRuleStatement() behave alike for switch expressions and statements using arrow rules.
|
||||
|
||||
switch(x) {
|
||||
case 1 -> f();
|
||||
case 2 -> f();
|
||||
default -> f();
|
||||
}
|
||||
|
||||
int result = switch(x) {
|
||||
case 1 -> f();
|
||||
case 2 -> f();
|
||||
default -> f();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
exprs
|
||||
| TestSwitchExpr.java:9:13:9:41 | case ... | TestSwitchExpr.java:9:43:9:46 | null |
|
||||
| TestSwitchExpr.java:10:13:10:22 | default | TestSwitchExpr.java:10:24:10:25 | x1 |
|
||||
| TestSwitchExprStmtConsistency.java:10:7:10:15 | case ... | TestSwitchExprStmtConsistency.java:10:17:10:19 | f(...) |
|
||||
| TestSwitchExprStmtConsistency.java:11:7:11:15 | case ... | TestSwitchExprStmtConsistency.java:11:17:11:19 | f(...) |
|
||||
| TestSwitchExprStmtConsistency.java:12:7:12:16 | default | TestSwitchExprStmtConsistency.java:12:18:12:20 | f(...) |
|
||||
| TestSwitchExprStmtConsistency.java:16:7:16:15 | case ... | TestSwitchExprStmtConsistency.java:16:17:16:19 | f(...) |
|
||||
| TestSwitchExprStmtConsistency.java:17:7:17:15 | case ... | TestSwitchExprStmtConsistency.java:17:17:17:19 | f(...) |
|
||||
| TestSwitchExprStmtConsistency.java:18:7:18:16 | default | TestSwitchExprStmtConsistency.java:18:18:18:20 | f(...) |
|
||||
stmts
|
||||
| TestSwitchExpr.java:13:13:13:28 | case ... | TestSwitchExpr.java:13:30:13:42 | { ... } |
|
||||
| TestSwitchExpr.java:14:13:14:22 | default | TestSwitchExpr.java:14:24:14:52 | throw ... |
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
query predicate exprs(SwitchCase sc, Expr e) { e = sc.getRuleExpression() }
|
||||
|
||||
query predicate stmts(SwitchCase sc, Stmt s) { s = sc.getRuleStatement() }
|
||||
Reference in New Issue
Block a user