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