Skip to content

Commit 0f94aaa

Browse files
Test the set applied as a method of this, and with this left out
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 889fb0e commit 0f94aaa

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎liquidjava-example/src/main/java/testSuite/CorrectStateValues.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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

‎liquidjava-example/src/main/java/testSuite/ErrorStateValues.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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"})
2323
class 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+
}

0 commit comments

Comments
 (0)