File: StubParserEnumTest.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 (51 lines) | stat: -rw-r--r-- 1,688 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
/*
 * @test
 * @summary Adapted test case for Issue 2147
 * https://github.com/typetools/checker-framework/issues/2147 using framework package quals
 *
 * @compile/fail/ref=WithoutStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound StubParserEnumTest.java
 * @compile/fail/ref=WithStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound -Astubs=StubParserEnum.astub StubParserEnumTest.java
 */

import static java.util.concurrent.TimeUnit.*;

import java.util.concurrent.TimeUnit;
import org.checkerframework.common.util.report.qual.*;

class StubParserEnumTest {

    @SuppressWarnings("report")
    enum MyTimeUnit {
        NANOSECONDS,
        MICROSECONDS,
        @ReportReadWrite
        MILLISECONDS,
        @ReportReadWrite
        SECONDS;

        @ReportCall
        long toMicros(long d) {
            return d;
        }
    }

    void readFromEnumInSource() {
        MyTimeUnit u1 = MyTimeUnit.SECONDS;
        MyTimeUnit u2 = MyTimeUnit.MILLISECONDS;
        MyTimeUnit u3 = MyTimeUnit.MICROSECONDS;
        MyTimeUnit u4 = MyTimeUnit.NANOSECONDS;
        long sUS = MyTimeUnit.SECONDS.toMicros(10);
    }

    void readFromEnumInStub() {
        TimeUnit u1 = TimeUnit.SECONDS;
        TimeUnit u2 = MILLISECONDS;
        TimeUnit u3 = TimeUnit.MICROSECONDS;
        TimeUnit u4 = NANOSECONDS;
        long sUS = TimeUnit.SECONDS.toMicros(10);
        long sNS = SECONDS.toNanos(10);
        long msMS = TimeUnit.MILLISECONDS.toMillis(10);
        long msUS = TimeUnit.MILLISECONDS.toMicros(10);
        long msNS = MILLISECONDS.toNanos(10);
    }
}