| 1 |
import org.checkerframework.common.value.qual.IntRange; |
| 2 |
|
| 3 |
public class RefinementGTE { |
| 4 |
|
| 5 |
void test_forward(int a, int j, int s) { |
| 6 |
/** forwards greater than or equals */ |
| 7 |
// :: error: (assignment.type.incompatible) |
| 8 |
@IntRange(from = -1) int aa = a; |
| 9 |
if (a >= -1) { |
| 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 (j >= 0) { |
| 17 |
@IntRange(from = 0) int k = j; |
| 18 |
// :: error: (assignment.type.incompatible) |
| 19 |
@IntRange(from = 1) int k1 = j; |
| 20 |
@IntRange(from = -1) int k2 = j; |
| 21 |
} else { |
| 22 |
// :: error: (assignment.type.incompatible) |
| 23 |
@IntRange(from = 0) int l = j; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
void test_backwards(int a, int j, int s) { |
| 28 |
/** backwards greater than or equal */ |
| 29 |
// :: error: (assignment.type.incompatible) |
| 30 |
@IntRange(from = 0) int aa = a; |
| 31 |
if (-1 >= a) { |
| 32 |
// :: error: (assignment.type.incompatible) |
| 33 |
@IntRange(from = 0) int b = a; |
| 34 |
} else { |
| 35 |
@IntRange(from = 0) int c = a; |
| 36 |
} |
| 37 |
|
| 38 |
if (0 >= j) { |
| 39 |
// :: error: (assignment.type.incompatible) |
| 40 |
@IntRange(from = 1) int k = j; |
| 41 |
} else { |
| 42 |
@IntRange(from = 1) int l = j; |
| 43 |
@IntRange(from = -1) int l1 = j; |
| 44 |
@IntRange(from = 0) int l2 = j; |
| 45 |
} |
| 46 |
|
| 47 |
if (1 >= s) { |
| 48 |
// :: error: (assignment.type.incompatible) |
| 49 |
@IntRange(from = 1) int t = s; |
| 50 |
} else { |
| 51 |
@IntRange(from = 1) int u = s; |
| 52 |
} |
| 53 |
} |
| 54 |
} |