summaryrefslogtreecommitdiff
path: root/Chalice/tests/predicates/test.chalice
diff options
context:
space:
mode:
authorGravatar stefanheule <unknown>2012-02-25 03:33:46 -0800
committerGravatar stefanheule <unknown>2012-02-25 03:33:46 -0800
commit43e00a07c7b28d7f51081b4cac736af0f3481600 (patch)
tree6f207575ed3b5da6517d4726f460bcaf46300fb3 /Chalice/tests/predicates/test.chalice
parente3662fe7db0f677d3497cc81286e93516f09ba73 (diff)
Chalice: New test case for predicates.
Diffstat (limited to 'Chalice/tests/predicates/test.chalice')
-rw-r--r--Chalice/tests/predicates/test.chalice38
1 files changed, 38 insertions, 0 deletions
diff --git a/Chalice/tests/predicates/test.chalice b/Chalice/tests/predicates/test.chalice
new file mode 100644
index 00000000..6c416671
--- /dev/null
+++ b/Chalice/tests/predicates/test.chalice
@@ -0,0 +1,38 @@
+class List
+{
+ var value:int;
+ var next:List;
+
+ predicate inv { acc(value) && acc(next) && (next!=null ==> next.inv) }
+
+ function len():int
+ requires inv;
+ {
+ unfolding inv in (next==null) ? 1 : (1+next.len())
+ }
+
+ predicate P { acc(value,50) }
+
+ method skip()
+ requires P; ensures P
+ {}
+
+ method goo()
+ requires acc(value);
+ {
+ // mask: value=100, secmask: -
+ fold P;
+ // mask: value=50,p=100, secmask: value=50
+ call skip();
+ // mask: value=50,p=100, secmask: -
+ fold P;
+ // mask: value=0,p=200, secmask: value=50
+ fork t:=skip();
+ // mask: value=0,p=100, secmask: -
+ assert unfolding P in value==old(value);
+ // ERROR: Chalice currently cannot verify this example, as there is neither
+ // primary nor secondary permission available to value directly before the
+ // assertion
+ }
+
+}