mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Add missing test Java files
This commit is contained in:
30
java/ql/test/library-tests/pattern-switch/dfg/GuardTest.java
Normal file
30
java/ql/test/library-tests/pattern-switch/dfg/GuardTest.java
Normal file
@@ -0,0 +1,30 @@
|
||||
public class GuardTest {
|
||||
|
||||
public static void sink(String s) { }
|
||||
public static boolean isSafe(String s) { return s.length() < 10; }
|
||||
|
||||
public static void test(Object o) {
|
||||
|
||||
switch (o) {
|
||||
|
||||
case String s:
|
||||
sink(s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
switch (o) {
|
||||
|
||||
case String s when isSafe(s):
|
||||
sink(s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user