summaryrefslogtreecommitdiff
path: root/Test/dafny4/set-compr.dfy
diff options
context:
space:
mode:
authorGravatar qunyanm <unknown>2015-03-31 09:17:26 -0700
committerGravatar qunyanm <unknown>2015-03-31 09:17:26 -0700
commitb4b193a05571b243d50a832dae58e837e779b710 (patch)
treee4c2f9707ee8c9bcb449a5e61b9d89be6f1cb7bc /Test/dafny4/set-compr.dfy
parent441eca2a4c02efcc555cb8ca25ac991ccee205f8 (diff)
Fix issue 61. Decreases are by default in ghost context. Therefore,
dontCareAboutCompilation flag should be set to false in the ResolveOpts.
Diffstat (limited to 'Test/dafny4/set-compr.dfy')
-rw-r--r--Test/dafny4/set-compr.dfy55
1 files changed, 55 insertions, 0 deletions
diff --git a/Test/dafny4/set-compr.dfy b/Test/dafny4/set-compr.dfy
new file mode 100644
index 00000000..71a07f3d
--- /dev/null
+++ b/Test/dafny4/set-compr.dfy
@@ -0,0 +1,55 @@
+// RUN: %dafny /compile:0 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+method M()
+ modifies set o: object | true // allowed, since comprehension is in ghost context
+{
+}
+
+method N()
+ requires null in set o: object | true // (X) allowed, since comprehension is in ghost context
+ ensures null in set o: object | true // (X) allowed, since comprehension is in ghost context
+ decreases set o: object | true // (X) allowed, since comprehension is in ghost context
+{
+ N();
+}
+
+method O() returns (ghost p: set<object>)
+{
+ assert null in set o: object | true; // (X) allowed -- in a ghost context
+ p := set o: object | true; // (X) allowed -- in a ghost context
+}
+
+method P() returns (p: set<object>)
+{
+ p := set o: object | true; // not allowed -- not in a ghost context
+}
+
+ghost method Q() returns (p: set<object>)
+{
+ p := set o: object | true; // allowed, since the whole method is ghost
+}
+
+function F(): int
+ requires null in set o: object | true // allowed
+ ensures null in set o: object | true // allowed
+ reads set o: object | true // allowed
+ decreases set o: object | true // allowed
+{
+ if null in set o: object | true then // allowed -- in a ghost context
+ F()
+ else
+ 0
+}
+
+function method G(): int
+ requires null in set o: object | true // (X) allowed
+ ensures null in set o: object | true // (X) allowed
+ reads set o: object | true // allowed
+ decreases set o: object | true // (X) allowed
+{
+ if null in set o: object | true then // not allowed, since this is not a ghost context
+ G()
+ else
+ 0
+}