Repository navigation
Expand file tree
/
Copy pathErrorLoopPostState.java
More file actions
90 lines (76 loc) · 2.28 KB
/
Copy pathErrorLoopPostState.java
File metadata and controls
90 lines (76 loc) · 2.28 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package testSuite;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@StateSet({"open", "marked"})
public class ErrorLoopPostState {
@StateRefinement(to = "open(this)")
ErrorLoopPostState() {}
@StateRefinement(to = "marked(this)")
void mark() {}
@StateRefinement(from = "marked(this)", to = "open(this)")
void reset() {}
@StateRefinement(from = "open(this)")
void use() {}
// Issue #338: the loop may run zero times, leaving b open.
static void whileMayBeEmpty(int n) {
ErrorLoopPostState b = new ErrorLoopPostState();
int k = 0;
while (k < n) {
b.mark();
k++;
}
b.reset(); // Expect: State Refinement Error
}
static void forMayBeEmpty(int n) {
ErrorLoopPostState b = new ErrorLoopPostState();
for (int k = 0; k < n; k++) {
b.mark();
}
b.reset(); // Expect: State Refinement Error
}
static void forEachMayBeEmpty(int[] values) {
ErrorLoopPostState b = new ErrorLoopPostState();
for (int value : values) {
b.mark();
}
b.reset(); // Expect: State Refinement Error
}
@StateRefinement(from = "open(this)")
void explicitThisMayBeEmpty(int n) {
while (n > 0) {
this.mark();
n--;
}
this.reset(); // Expect: State Refinement Error
}
@StateRefinement(from = "open(this)")
void implicitThisMayBeEmpty(int n) {
while (n > 0) {
mark();
n--;
}
reset(); // Expect: State Refinement Error
}
@StateRefinement(from = "open(this)")
void laterIteration(int n) {
while (n > 0) {
use(); // Expect: State Refinement Error
mark();
n--;
}
}
@StateRefinement(from = "open(this)")
void directInvalidCall() {
this.reset(); // Expect: State Refinement Error
}
@StateRefinement(from = "open(this)")
void directInvalidSequence() {
mark();
use(); // Expect: State Refinement Error
}
@StateRefinement(from = "open(this)")
@StateRefinement(from = "marked(this)")
void unionDoesNotImplyOneState() {
use(); // Expect: State Refinement Error
}
}