File tree Expand file tree Collapse file tree
liquidjava-example/src/main/java/testSuite Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ public CorrectStateValues() {}
2121 @ StateRefinement (from = "door(this) == closed && lock(this) != locked" , to = "door(this) == opened" )
2222 public void open () {}
2323
24- @ StateRefinement (from = "door(this) == opened" , to = "door(this) == closed" )
24+ // the set can also be applied as a method of this, or with this left out
25+ @ StateRefinement (from = "this.door() == opened" , to = "door() == closed" )
2526 public void close () {}
2627
2728 // when it fails, the lock set keeps its value
@@ -30,7 +31,7 @@ public boolean tryLock() {
3031 return true ;
3132 }
3233
33- @ StateRefinement (from = "lock(this) == locked " , to = "lock(this) == unlocked " )
34+ @ StateRefinement (from = "locked == this.lock() " , to = "lock() != locked " )
3435 public void unlock () {}
3536
3637 // the parameter closed keeps its meaning: the door takes its value
Original file line number Diff line number Diff line change @@ -21,3 +21,18 @@ class ErrorStateValuesGeneratedSetName {}
2121// an unrelated set named door that has a state locked does not make locked a state of the door above
2222@ StateSet (name = "door" , value = {"locked" , "free" })
2323class ErrorStateValuesOtherDoor {}
24+
25+ // the set applied as a method of this, or with this left out, constrains the same state
26+ @ StateSet (name = "door" , value = {"shut" , "ajar" })
27+ class ErrorStateValueForms {
28+
29+ @ StateRefinement (to = "door() == shut" )
30+ public ErrorStateValueForms () {}
31+
32+ @ StateRefinement (from = "this.door() == ajar" )
33+ public void close () {}
34+
35+ static void test () {
36+ new ErrorStateValueForms ().close (); // Expect: State Refinement Error
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments