summaryrefslogtreecommitdiff
path: root/Test/dafny1
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2011-02-16 23:27:45 +0000
committerGravatar rustanleino <unknown>2011-02-16 23:27:45 +0000
commit3baf091750430d9f94cd75ac0334d54748f7a8c0 (patch)
treed86742031f9d5c01e994aa835c65c57c6072c4dc /Test/dafny1
parent5c4a74e91741c00f4250c43eca12a9b8b45ecd96 (diff)
Dafny: added test harness to Test/dafny1/ExtensibleArray.dfy
Diffstat (limited to 'Test/dafny1')
-rw-r--r--Test/dafny1/Answer2
-rw-r--r--Test/dafny1/ExtensibleArray.dfy22
2 files changed, 22 insertions, 2 deletions
diff --git a/Test/dafny1/Answer b/Test/dafny1/Answer
index 58d36d2d..a6fb57a7 100644
--- a/Test/dafny1/Answer
+++ b/Test/dafny1/Answer
@@ -13,7 +13,7 @@ Dafny program verifier finished with 24 verified, 0 errors
-------------------- ExtensibleArray.dfy --------------------
-Dafny program verifier finished with 9 verified, 0 errors
+Dafny program verifier finished with 11 verified, 0 errors
-------------------- BinaryTree.dfy --------------------
diff --git a/Test/dafny1/ExtensibleArray.dfy b/Test/dafny1/ExtensibleArray.dfy
index e60ab8ae..810931be 100644
--- a/Test/dafny1/ExtensibleArray.dfy
+++ b/Test/dafny1/ExtensibleArray.dfy
@@ -89,7 +89,7 @@ class ExtensibleArray<T> {
// there is room in "elements"
elements[length - M] := t;
} else {
- if (length == 256) {
+ if (more == null) {
var mr := new ExtensibleArray<array<T>>; more := mr;
call mr.Init();
Repr := Repr + {mr} + mr.Repr;
@@ -106,3 +106,23 @@ class ExtensibleArray<T> {
Contents := Contents + [t];
}
}
+
+method Main() {
+ var a := new ExtensibleArray<int>;
+ call a.Init();
+ var n := 0;
+ while (n < 256*256+600)
+ invariant a.Valid() && fresh(a.Repr);
+ invariant |a.Contents| == n;
+ {
+ call a.Append(n);
+ n := n + 1;
+ }
+ call k := a.Get(570); print k, "\n";
+ call k := a.Get(0); print k, "\n";
+ call k := a.Get(1000); print k, "\n";
+ call a.Set(1000, 23);
+ call k := a.Get(0); print k, "\n";
+ call k := a.Get(1000); print k, "\n";
+ call k := a.Get(66000); print k, "\n";
+}