DFA: support subtraction and unary negation (IDEA-184800)

This commit is contained in:
Tagir Valeev
2018-01-12 12:37:38 +07:00
parent 30b3d4a558
commit 4eb8fa52f3
7 changed files with 189 additions and 60 deletions
@@ -1,6 +1,6 @@
import java.util.*;
public class LongRangeAdd {
public class LongRangePlusMinus {
void test(int x, int y) {
if (x > 0 && x < 10) {
if (<warning descr="Condition 'y > x + 10 && y < 0' is always 'false'">y > x + 10 &&
@@ -39,4 +39,34 @@ public class LongRangeAdd {
}
}
}
void testMinus(int offset) {
if(offset <= 0) return;
if(<warning descr="Condition 'offset - 1 >= 0' is always 'true'">offset - 1 >= 0</warning>) {
System.out.println("always");
}
}
void testMinusInLoop() {
for(int i=0; i<10; i++) {
for(int j=11; j<20; j++) {
if(<warning descr="Condition 'j - i < 0' is always 'false'">j - i < 0</warning>) {
System.out.println("Impossible");
}
}
}
}
void testNegateInLoop(int[] arr) {
int x = 1;
for(int val : arr) {
x = -x;
if (val == x) {
System.out.println("ok");
if (<warning descr="Condition 'val > 3' is always 'false'">val > 3</warning>) {
System.out.println("Impossible");
}
}
}
}
}