Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/LongRangeAnnotation.java
Tagir Valeev 1ad304b30c DfaFactType: fixed default range for float/double; tests
Fixes test DataFlowRangeAnalysisTest.testLongRangeBasics
2017-10-06 11:38:50 +07:00

29 lines
699 B
Java

import javax.annotation.Nonnegative;
import java.util.Random;
public class LongRangeAnnotation {
@Nonnegative int method() {
return new Random().nextInt(100);
}
@Nonnegative int x;
@Nonnegative double y;
void testField() {
if(<warning descr="Condition 'x < 0' is always 'false'">x < 0</warning>) {
System.out.println("Impossible");
}
if(y < 0) {
System.out.println("Doubles are not supported yet");
}
}
void testAnnotated() {
int value = method();
if(value == 0) {
System.out.println("Zero");
} else if(<warning descr="Condition 'value > 0' is always 'true'">value > 0</warning>) {
System.out.println("Positive");
}
}
}