summaryrefslogtreecommitdiff
path: root/Test/dafny0/PredExpr.dfy
diff options
context:
space:
mode:
authorGravatar qadeer <qadeer@microsoft.com>2011-11-16 09:36:41 -0800
committerGravatar qadeer <qadeer@microsoft.com>2011-11-16 09:36:41 -0800
commit1fc8bd36cc4320fa6a7796c05f6805ecb3594fc8 (patch)
treedf546a2ac37373e4c3226eaf42890e4e500d6462 /Test/dafny0/PredExpr.dfy
parentf93b56972e92b21490e00e886346e2af427fd22b (diff)
parentabff937f2144b0ea68cc8936bb411d113bd1b687 (diff)
Merge
Diffstat (limited to 'Test/dafny0/PredExpr.dfy')
-rw-r--r--Test/dafny0/PredExpr.dfy30
1 files changed, 29 insertions, 1 deletions
diff --git a/Test/dafny0/PredExpr.dfy b/Test/dafny0/PredExpr.dfy
index 740c2308..96561ebd 100644
--- a/Test/dafny0/PredExpr.dfy
+++ b/Test/dafny0/PredExpr.dfy
@@ -1,3 +1,16 @@
+function SimpleAssert(n: int): int
+ ensures n < 100;
+{
+ assert n == 58; // error: assert violation
+ n // but postcondition is fine
+}
+
+function SimpleAssume(n: int): int
+ ensures n < 100;
+{
+ assume n == 58; n // all is fine
+}
+
function Subonacci(n: nat): nat
{
if 2 <= n then
@@ -18,7 +31,7 @@ function F(n: int): nat
function G(n: int, b: bool): nat
{
if b then
- Subonacci(assume 0 <= n; n)
+ Subonacci(assume 0 <= n; n) + n // the last n is also affected by the assume
else
Subonacci(n) // error: n may not be a nat
}
@@ -49,3 +62,18 @@ function method FuncMeth(): int {
// PredicateExpr is not included in compilation
15
}
+
+method M5(a: int, b: int)
+{
+ var k := if a < 0 then
+ assume b < 0; 5
+ else
+ 5;
+ if (*) {
+ assert a == -7 ==> b < 0;
+ assert b < 0; // error: this condition does not hold on every path here
+ } else {
+ assert assume a == -7; b < 0; // note, this is different than the ==> above
+ assert b < 0; // this condition does hold on all paths to here
+ }
+}