summaryrefslogtreecommitdiff
path: root/Test/civl/t1.bpl
diff options
context:
space:
mode:
Diffstat (limited to 'Test/civl/t1.bpl')
-rw-r--r--Test/civl/t1.bpl103
1 files changed, 103 insertions, 0 deletions
diff --git a/Test/civl/t1.bpl b/Test/civl/t1.bpl
new file mode 100644
index 00000000..ef468347
--- /dev/null
+++ b/Test/civl/t1.bpl
@@ -0,0 +1,103 @@
+// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+function {:builtin "MapConst"} mapconstbool(bool) : [int]bool;
+
+function {:builtin "MapConst"} MapConstBool(bool) : [int]bool;
+function {:inline} {:linear "tid"} TidCollector(x: int) : [int]bool
+{
+ MapConstBool(false)[x := true]
+}
+
+function {:inline} {:linear "1"} SetCollector1(x: [int]bool) : [int]bool
+{
+ x
+}
+
+function {:inline} {:linear "2"} SetCollector2(x: [int]bool) : [int]bool
+{
+ x
+}
+
+var {:layer 0,1} g: int;
+var {:layer 0,1} h: int;
+
+procedure {:yields} {:layer 0,1} SetG(val:int);
+ensures {:atomic} |{A: g := val; return true; }|;
+
+procedure {:yields} {:layer 0,1} SetH(val:int);
+ensures {:atomic} |{A: h := val; return true; }|;
+
+procedure {:yields} {:layer 1} Yield({:linear "1"} x: [int]bool)
+requires {:layer 1} x == mapconstbool(true) && g == 0;
+ensures {:layer 1} x == mapconstbool(true) && g == 0;
+{
+ yield;
+ assert {:layer 1} x == mapconstbool(true) && g == 0;
+}
+
+procedure {:yields} {:layer 1} Allocate() returns ({:linear "tid"} xl: int)
+ensures {:layer 1} xl != 0;
+{
+ yield;
+ call xl := AllocateLow();
+ yield;
+}
+
+procedure {:yields} {:layer 0,1} AllocateLow() returns ({:linear "tid"} xls: int);
+ensures {:atomic} |{ A: assume xls != 0; return true; }|;
+
+procedure {:yields} {:layer 1} A({:linear_in "tid"} tid_in: int, {:linear_in "1"} x: [int]bool, {:linear_in "2"} y: [int]bool) returns ({:linear "tid"} tid_out: int)
+requires {:layer 1} x == mapconstbool(true);
+requires {:layer 1} y == mapconstbool(true);
+{
+ var {:linear "tid"} tid_child: int;
+ tid_out := tid_in;
+
+ yield;
+ call SetG(0);
+
+ par tid_child := Allocate() | Yield(x);
+
+ async call B(tid_child, x);
+
+ yield;
+ assert {:layer 1} x == mapconstbool(true);
+ assert {:layer 1} g == 0;
+
+ call SetH(0);
+
+ yield;
+ assert {:layer 1} h == 0 && y == mapconstbool(true);
+
+ yield;
+ call tid_child := Allocate();
+ async call C(tid_child, y);
+
+ yield;
+}
+
+procedure {:yields} {:layer 1} B({:linear_in "tid"} tid_in: int, {:linear_in "1"} x_in: [int]bool)
+requires {:layer 1} x_in != mapconstbool(false);
+{
+ var {:linear "tid"} tid_out: int;
+ var {:linear "1"} x: [int]bool;
+ tid_out := tid_in;
+ x := x_in;
+
+ yield;
+ call SetG(1);
+ yield;
+}
+
+procedure {:yields} {:layer 1} C({:linear_in "tid"} tid_in: int, {:linear_in "2"} y_in: [int]bool)
+requires {:layer 1} y_in != mapconstbool(false);
+{
+ var {:linear "tid"} tid_out: int;
+ var {:linear "2"} y: [int]bool;
+ tid_out := tid_in;
+ y := y_in;
+
+ yield;
+ call SetH(1);
+ yield;
+}