Skip to content

Commit 5aae07e

Browse files
committed
Update Tests
1 parent 90007df commit 5aae07e

File tree

11 files changed

+108
-51
lines changed

11 files changed

+108
-51
lines changed

liquidjava-example/src/main/java/testBooleanGhost/BooleanGhostClass.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

liquidjava-example/src/main/java/testBooleanGhost/BooleanGhostTest.java

Lines changed: 0 additions & 12 deletions
This file was deleted.
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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package testSuite.classes.vending_machine_correct;
2+
3+
import liquidjava.specification.Ghost;
4+
import liquidjava.specification.StateRefinement;
5+
6+
@Ghost("double value")
7+
public class VendingMachine {
8+
9+
@StateRefinement(from = "value(this) >= 0.0", to = "value(this) == value(old(this)) + 0.1")
10+
void insertTenCents() {}
11+
12+
@StateRefinement(from = "value(this) >= 0.3")
13+
void buy() {}
14+
}

0 commit comments

Comments
 (0)