Skip to content

Commit 1c5a495

Browse files
authored
Merge branch 'main' into decouple-z3
2 parents f5879a9 + d3c2dbb commit 1c5a495

File tree

32 files changed

+1174
-83
lines changed

32 files changed

+1174
-83
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ To run LiquidJava, use the Maven command below, replacing `/path/to/your/project
5555
```bash
5656
mvn exec:java -pl liquidjava-verifier -Dexec.mainClass="liquidjava.api.CommandLineLauncher" -Dexec.args="/path/to/your/project"
5757
```
58+
*Warning: Any change to LiquidJava requires rebuilding the jar.*
59+
5860

5961
If you're on Linux/macOS, you can use the `liquidjava` script (from the repository root) to simplify the process.
6062

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+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package testSuite.classes.boolean_ghost_correct;
2+
3+
import liquidjava.specification.Ghost;
4+
import liquidjava.specification.StateRefinement;
5+
6+
@Ghost("boolean open")
7+
public class SimpleStateMachine {
8+
9+
@StateRefinement(from = "!open(this)", to = "open(this)")
10+
void open() {}
11+
12+
@StateRefinement(from = "open(this)")
13+
void execute() {}
14+
15+
@StateRefinement(from = "open(this)", to = "!open(this)")
16+
void close() {}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package testSuite.classes.boolean_ghost_correct;
2+
3+
public class SimpleTest {
4+
public static void main(String[] args) {
5+
SimpleStateMachine ssm = new SimpleStateMachine();
6+
ssm.open();
7+
ssm.execute();
8+
ssm.close();
9+
}
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package testSuite.classes.boolean_ghost_error;
2+
3+
import liquidjava.specification.Ghost;
4+
import liquidjava.specification.StateRefinement;
5+
6+
@Ghost("boolean open")
7+
public class SimpleStateMachine {
8+
9+
@StateRefinement(from = "!open(this)", to = "open(this)")
10+
void open() {}
11+
12+
@StateRefinement(from = "open(this)")
13+
void execute() {}
14+
15+
@StateRefinement(from = "open(this)", to = "!open(this)")
16+
void close() {}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package testSuite.classes.boolean_ghost_error;
2+
3+
public class SimpleTest {
4+
public static void main(String[] args) {
5+
SimpleStateMachine ssm = new SimpleStateMachine();
6+
ssm.open();
7+
ssm.close();
8+
ssm.execute(); // error, not open
9+
}
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package testSuite.classes.scoreboard_error;
2+
3+
import liquidjava.specification.Ghost;
4+
import liquidjava.specification.StateRefinement;
5+
6+
@Ghost("double value")
7+
public class Scoreboard {
8+
9+
@StateRefinement(from = "value(this) < 1.0", to = "value(this) == value(old(this)) + 0.1")
10+
public void inc() {}
11+
12+
@StateRefinement(from = "value(this) > 0.0", to = "value(this) == value(old(this)) - 0.1")
13+
public void dec() {}
14+
15+
@StateRefinement(from = "value(this) > 0.0")
16+
public void finish() {}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package testSuite.classes.scoreboard_error;
2+
3+
public class SimpleTest {
4+
public static void main(String[] args) {
5+
Scoreboard sb = new Scoreboard();
6+
sb.inc();
7+
sb.dec();
8+
sb.dec(); // error, underflow
9+
sb.finish();
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package testSuite.classes.vending_machine_correct;
2+
3+
public class SimpleTest {
4+
public static void main(String[] args) {
5+
VendingMachine vm = new VendingMachine(); // 30 cents to buy
6+
vm.insertTenCents();
7+
vm.insertTenCents();
8+
vm.insertTenCents();
9+
vm.buy();
10+
}
11+
}

0 commit comments

Comments
 (0)