| 1 |
/* |
| 2 |
* @test |
| 3 |
* @summary Adapted test case for Issue 2147 |
| 4 |
* https://github.com/typetools/checker-framework/issues/2147 using framework package quals |
| 5 |
* |
| 6 |
* @compile/fail/ref=WithoutStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound StubParserEnumTest.java |
| 7 |
* @compile/fail/ref=WithStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound -Astubs=StubParserEnum.astub StubParserEnumTest.java |
| 8 |
*/ |
| 9 |
|
| 10 |
import static java.util.concurrent.TimeUnit.*; |
| 11 |
|
| 12 |
import java.util.concurrent.TimeUnit; |
| 13 |
import org.checkerframework.common.util.report.qual.*; |
| 14 |
|
| 15 |
class StubParserEnumTest { |
| 16 |
|
| 17 |
@SuppressWarnings("report") |
| 18 |
enum MyTimeUnit { |
| 19 |
NANOSECONDS, |
| 20 |
MICROSECONDS, |
| 21 |
@ReportReadWrite |
| 22 |
MILLISECONDS, |
| 23 |
@ReportReadWrite |
| 24 |
SECONDS; |
| 25 |
|
| 26 |
@ReportCall |
| 27 |
long toMicros(long d) { |
| 28 |
return d; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
void readFromEnumInSource() { |
| 33 |
MyTimeUnit u1 = MyTimeUnit.SECONDS; |
| 34 |
MyTimeUnit u2 = MyTimeUnit.MILLISECONDS; |
| 35 |
MyTimeUnit u3 = MyTimeUnit.MICROSECONDS; |
| 36 |
MyTimeUnit u4 = MyTimeUnit.NANOSECONDS; |
| 37 |
long sUS = MyTimeUnit.SECONDS.toMicros(10); |
| 38 |
} |
| 39 |
|
| 40 |
void readFromEnumInStub() { |
| 41 |
TimeUnit u1 = TimeUnit.SECONDS; |
| 42 |
TimeUnit u2 = MILLISECONDS; |
| 43 |
TimeUnit u3 = TimeUnit.MICROSECONDS; |
| 44 |
TimeUnit u4 = NANOSECONDS; |
| 45 |
long sUS = TimeUnit.SECONDS.toMicros(10); |
| 46 |
long sNS = SECONDS.toNanos(10); |
| 47 |
long msMS = TimeUnit.MILLISECONDS.toMillis(10); |
| 48 |
long msUS = TimeUnit.MILLISECONDS.toMicros(10); |
| 49 |
long msNS = MILLISECONDS.toNanos(10); |
| 50 |
} |
| 51 |
} |