Java: Add test for range analysis

This commit is contained in:
Tamas Vajk
2020-09-11 10:11:23 +02:00
parent d095d6b56b
commit c66473cb8a
3 changed files with 223 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
public class A {
int f1(int x, int y) {
if (x < 500) {
if (x > 400) {
return x;
}
if (y - 2 == x && y > 300) {
return x + y;
}
if (x != y + 1) {
int sum = x + y; // x <= 400
} else {
if (y > 300) {
int sum = x + y; // 302 <= x <= 400, y = x - 1, 301 <= y <= 399
}
}
if (x > 500) {
return x;
}
}
return 0;
}
int f2(int x, int y, int z) {
if (x < 500) {
if (x > 400) {
return x;
}
if (y == x - 1 && y > 300 && y + 2 == z && z == 350) {
return x + y + z;
}
}
return 0;
}
}