File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
liquidjava-example/src/main/java/testBooleanGhost Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package testBooleanGhost ;
2+
3+ import liquidjava .specification .Ghost ;
4+ import liquidjava .specification .StateRefinement ;
5+
6+ @ Ghost ("boolean opened" )
7+ @ Ghost ("boolean closed" )
8+ public class BooleanGhostClass {
9+
10+ boolean opened ;
11+ boolean closed ;
12+
13+ @ StateRefinement (from = "!opened(this) && !closed(this)" , to = "opened(this) && !closed(this)" )
14+ void open () {
15+ opened = true ;
16+ }
17+
18+ @ StateRefinement (from = "opened(this) && !closed(this)" )
19+ void execute () {
20+ // System.out.println("opened:" + open + "\nclosed::" + closed); // lança
21+ // exceção
22+
23+ System .out .println ("opened: " );
24+ System .out .println (opened );
25+ System .out .println ("\n closed: " );
26+ System .out .println (closed );
27+
28+ }
29+
30+ @ StateRefinement (from = "opened(this) && !closed(this)" , to = "opened(this) && closed(this)" )
31+ void close () {
32+ closed = true ;
33+ }
34+
35+ @ StateRefinement (from = "opened(this) && closed(this)" )
36+ void terminate () {
37+ System .out .println ("Terminating\n " );
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ package testBooleanGhost ;
2+
3+ public class BooleanGhostTest {
4+ public static void main (String [] args ) {
5+ BooleanGhostClass bgc = new BooleanGhostClass ();
6+
7+ bgc .open (); // ccomment out for error
8+ bgc .execute ();
9+ bgc .close (); // comment out for error
10+ bgc .terminate ();
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments