Repository navigation
Expand file tree
/
Copy pathErrorStateHintNaming.java
More file actions
59 lines (45 loc) · 1.88 KB
/
Copy pathErrorStateHintNaming.java
File metadata and controls
59 lines (45 loc) · 1.88 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
package testSuite;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
// The needed and current states are named only in the state sets that matter
@StateSet({"created", "open", "ready"})
@StateSet({"quiet", "loud"})
public class ErrorStateHintNaming {
@StateRefinement(to = "created(this) && quiet(this)")
public ErrorStateHintNaming() {}
// a state of either set: each is named alone, not combined with every state of the other set
@StateRefinement(from = "open(this) || loud(this)")
public void read() {}
public static void use(ErrorStateHintNaming s) {
s.read(); // Expect: State Refinement Error
}
}
// every state allows flip(), each by its own refinement: a or b, not all six states
@StateSet({"a", "b"})
@StateSet({"x", "y", "z"})
class ErrorStateHintNamingToggle {
@StateRefinement(to = "a(this) && x(this)")
public ErrorStateHintNamingToggle() {}
@StateRefinement(from = "a(this)", to = "b(this)")
@StateRefinement(from = "b(this)", to = "a(this)")
public void flip() {}
public static void use(ErrorStateHintNamingToggle t) {
t.flip(); // Expect: State Refinement Error
}
}
// known in one of three state sets: only that set is named
@StateSet({"start", "canEdit", "end"})
@StateSet({"undoable", "notUndoable"})
@StateSet({"redoable", "notRedoable"})
class ErrorStateHintNamingPartlyKnown {
@StateRefinement(to = "start(this) && notUndoable(this) && notRedoable(this)")
public ErrorStateHintNamingPartlyKnown() {}
@StateRefinement(from = "redoable(this)", to = "undoable(this) && notRedoable(this)")
public void redo() {}
@StateRefinement(from = "undoable(this)", to = "notUndoable(this) && redoable(this)")
public void undo() {}
@StateRefinement(from = "notRedoable(this)")
public void check() {
this.redo(); // Expect: State Refinement Error
}
}