mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Migrate Java code to separate QL repo.
This commit is contained in:
35
java/ql/test/query-tests/UselessComparisonTest/Test.java
Normal file
35
java/ql/test/query-tests/UselessComparisonTest/Test.java
Normal file
@@ -0,0 +1,35 @@
|
||||
class Test {
|
||||
private int z;
|
||||
void test(int x) {
|
||||
z = getInt();
|
||||
if (x < 0 || z < 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
int y = 0;
|
||||
if (x >= 0) y++; // useless test due to test in line 5 being false
|
||||
if (z >= 0) y++; // useless test due to test in line 5 being false
|
||||
while(x >= 0) {
|
||||
if (y < 10) {
|
||||
z++;
|
||||
if (y == 15) z++; // useless test due to test in line 12 being true
|
||||
y++;
|
||||
z--;
|
||||
} else if (y > 7) { // useless test due to test in line 12 being false
|
||||
y--;
|
||||
}
|
||||
if (!(y != 5) && z >= 0) { // z >= 0 is always true due to line 5 (and z being increasing)
|
||||
int w = y < 3 ? 0 : 1; // useless test due to test in line 20 being true
|
||||
}
|
||||
x--;
|
||||
}
|
||||
}
|
||||
void test2(int x) {
|
||||
if (x != 0) {
|
||||
int w = x == 0 ? 1 : 2; // useless test due to test in line 27 being true
|
||||
x--;
|
||||
} else if (x == 0) { // useless test due to test in line 27 being false
|
||||
x++;
|
||||
}
|
||||
}
|
||||
int getInt() { return 0; }
|
||||
}
|
||||
Reference in New Issue
Block a user