summaryrefslogtreecommitdiff
path: root/Test/dafny0
diff options
context:
space:
mode:
authorGravatar Jason Koenig <unknown>2011-07-08 14:50:26 -0700
committerGravatar Jason Koenig <unknown>2011-07-08 14:50:26 -0700
commit8ff2b0f8bebfcb55cb29ba70813bc644e8f6ad0c (patch)
tree4e808852995b4eb74497c1fbab3c620215fdc684 /Test/dafny0
parente38004bfdb8558d9fa3f4054d507cf35ada2e7c8 (diff)
Dafny: Added Euclidean regression test (Verifier only).
Diffstat (limited to 'Test/dafny0')
-rw-r--r--Test/dafny0/Answer2
-rw-r--r--Test/dafny0/Basics.dfy14
2 files changed, 15 insertions, 1 deletions
diff --git a/Test/dafny0/Answer b/Test/dafny0/Answer
index a29c64fa..7a972f22 100644
--- a/Test/dafny0/Answer
+++ b/Test/dafny0/Answer
@@ -657,7 +657,7 @@ Execution trace:
(0,0): anon8
(0,0): anon14_Then
-Dafny program verifier finished with 16 verified, 11 errors
+Dafny program verifier finished with 19 verified, 11 errors
-------------------- ControlStructures.dfy --------------------
ControlStructures.dfy(5,3): Error: missing case in case statement: Blue
diff --git a/Test/dafny0/Basics.dfy b/Test/dafny0/Basics.dfy
index 1ae5b9c4..6aa1e34d 100644
--- a/Test/dafny0/Basics.dfy
+++ b/Test/dafny0/Basics.dfy
@@ -171,3 +171,17 @@ method SwapEm(a: int, b: int) returns (x: int, y: int)
{
x, y := b, a;
}
+
+function method abs(a:int): int
+{
+ if a <= 0 then -a else a
+}
+// test of verifier using euclidean division.
+method EuclideanTest(a: int, b: int)
+ requires b != 0;
+{
+ var q, r := a / b, a % b;
+ assert 0 <= r < abs(b);
+ assert a == b * q + r;
+ assert (a/b) * b + a % b == a;
+} \ No newline at end of file