| 1 |
import org.checkerframework.common.value.qual.IntRange; |
| 2 |
|
| 3 |
public class RefinementGT { |
| 4 |
|
| 5 |
void test_forward(int a, int j, int s) { |
| 6 |
/** forwards greater than */ |
| 7 |
// :: error: (assignment.type.incompatible) |
| 8 |
@IntRange(from = 0) int aa = a; |
| 9 |
if (a > -1) { |
| 10 |
/** a is NN now */ |
| 11 |
@IntRange(from = 0) int b = a; |
| 12 |
@IntRange(from = -1) int b1 = a; |
| 13 |
// :: error: (assignment.type.incompatible) |
| 14 |
@IntRange(from = 1) int b2 = a; |
| 15 |
} else { |
| 16 |
// :: error: (assignment.type.incompatible) |
| 17 |
@IntRange(from = 0) int c = a; |
| 18 |
} |
| 19 |
|
| 20 |
if (j > 0) { |
| 21 |
/** j is POS now */ |
| 22 |
@IntRange(from = 1) int k = j; |
| 23 |
} else { |
| 24 |
// :: error: (assignment.type.incompatible) |
| 25 |
@IntRange(from = 1) int l = j; |
| 26 |
} |
| 27 |
|
| 28 |
if (s > 1) { |
| 29 |
@IntRange(from = 1) int t = s; |
| 30 |
} else { |
| 31 |
// :: error: (assignment.type.incompatible) |
| 32 |
@IntRange(from = 1) int u = s; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
void test_backwards(int a, int j, int s) { |
| 37 |
/** backwards greater than */ |
| 38 |
// :: error: (assignment.type.incompatible) |
| 39 |
@IntRange(from = 0) int aa = a; |
| 40 |
if (-1 > a) { |
| 41 |
// :: error: (assignment.type.incompatible) |
| 42 |
@IntRange(from = -1) int b = a; |
| 43 |
} else { |
| 44 |
@IntRange(from = -1) int c = a; |
| 45 |
// :: error: (assignment.type.incompatible) |
| 46 |
@IntRange(from = 0) int c1 = a; |
| 47 |
// :: error: (assignment.type.incompatible) |
| 48 |
@IntRange(from = 1) int c2 = a; |
| 49 |
} |
| 50 |
|
| 51 |
if (0 > j) { |
| 52 |
// :: error: (assignment.type.incompatible) |
| 53 |
@IntRange(from = 0) int k = j; |
| 54 |
} else { |
| 55 |
@IntRange(from = 0) int l = j; |
| 56 |
} |
| 57 |
|
| 58 |
if (1 > s) { |
| 59 |
// :: error: (assignment.type.incompatible) |
| 60 |
@IntRange(from = 1) int t = s; |
| 61 |
} else { |
| 62 |
@IntRange(from = 1) int u = s; |
| 63 |
} |
| 64 |
} |
| 65 |
} |