File: Unaries.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 (60 lines) | stat: -rw-r--r-- 1,360 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
import org.checkerframework.common.value.qual.*;

class Unaries {

    public void complement() {
        boolean a = false;
        @BoolVal({true}) boolean b = !a;

        @IntVal({-5}) int c = ~4;

        @IntVal({-123456789}) long d = ~123456788;
    }

    public void prefix() {
        byte a = 1;
        @IntVal({2}) byte b = ++a;

        @IntVal({3}) short c = ++a;

        @IntVal({4}) int d = ++a;

        @IntVal({5}) long e = ++a;
        ++a;
        e = --a;
        d = --a;
        c = --a;
        b = --a;
    }

    public void postfix() {
        int a = 0;
        @IntVal({0}) int b = a++;
        @IntVal({1}) int c = a--;
        b = a++;

        @IntVal({1}) long d = a--;

        double e = 0.25;
        @DoubleVal({0.25}) double f = e++;
        @DoubleVal({1.25}) double g = e--;
        f = e;
    }

    public void plusminus() {
        @IntVal({48}) int a = +48;
        @IntVal({-49}) int b = -49;

        @IntVal({34}) long c = +34;
        @IntVal({-34}) long d = -34;
    }

    public void intRange(@IntRange(from = 0, to = 2) int val) {
        int a = val;
        @IntRange(from = -2, to = 0) int b = -a;
        @IntRange(from = 0, to = 2) int c = +a;
        @IntRange(from = -3, to = -1) int d = ~a;
        @IntRange(from = 1, to = 3) int e = ++a;
        @IntRange(from = 1, to = 3) int f = a++;
    }
}