Skip to content

Commit f1a3f97

Browse files
added elementary testing for boolean ghost variables
1 parent 31ec501 commit f1a3f97

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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("\nclosed: ");
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+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}

0 commit comments

Comments
 (0)