File: RefineUnknownToIntRange.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (45 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import org.checkerframework.common.value.qual.BoolVal;
import org.checkerframework.common.value.qual.IntRange;

public class RefineUnknownToIntRange {
    void test1(int x) {
        if (x > 1) {
            @IntRange(from = 2) int z = x;
        }

        if (x < 1) {
            @IntRange(to = 0) int z = x;
        }

        if (1 < x) {
            @IntRange(from = 2) int z = x;
        }

        if (1 > x) {
            @IntRange(to = 0) int z = x;
        }

        if (x >= 1) {
            @IntRange(from = 1) int z = x;
        }

        if (x <= 1) {
            @IntRange(to = 1) int z = x;
        }

        if (x < 100 && x > 2) {
            @IntRange(from = 3, to = 99) int z = x;
        }
    }

    void test3(boolean x) {
        // Make sure non int values are ignored.
        if (x == false) {
            @BoolVal(false) boolean y = x;
        }

        Object o = new Object();
        Object o2 = new Object();
        if (o == o2) {}
    }
}