File: TransferAdd.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 (82 lines) | stat: -rw-r--r-- 2,264 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import org.checkerframework.common.value.qual.*;

public class TransferAdd {

    void test() {

        // adding zero and one and two

        int a = -1;

        @IntRange(from = 1) int a1 = a + 2;

        @IntRange(from = 0) int b = a + 1;
        @IntRange(from = 0) int c = 1 + a;

        @IntRange(from = -1) int d = a + 0;
        @IntRange(from = -1) int e = 0 + a;

        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int f = a + 1;

        @IntRange(from = 0) int g = b + 0;

        @IntRange(from = 1) int h = b + 1;

        @IntRange(from = 1) int i = h + 1;
        @IntRange(from = 1) int j = h + 0;

        // adding values

        @IntRange(from = 1) int k = i + j;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int l = b + c;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int m = d + c;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int n = d + e;

        @IntRange(from = 1) int o = h + g;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int p = h + d;

        @IntRange(from = 0) int q = b + c;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 0) int r = q + d;

        @IntRange(from = 0) int s = k + d;
        @IntRange(from = -1) int t = s + d;

        // increments

        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int u = b++;

        @IntRange(from = 1) int u1 = b;

        @IntRange(from = 1) int v = ++c;

        @IntRange(from = 1) int v1 = c;

        int n1p1 = -1, n1p2 = -1;

        @IntRange(from = 0) int w = ++n1p1;

        @IntRange(from = 0) int w1 = n1p1;

        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int w2 = n1p1;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int w3 = n1p1++;

        // :: error: (assignment.type.incompatible)
        @IntRange(from = 0) int x = n1p2++;

        @IntRange(from = 0) int x1 = n1p2;

        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int y = ++d;
        // :: error: (assignment.type.incompatible)
        @IntRange(from = 1) int z = e++;
    }
}