diff options
author | rustanleino <unknown> | 2011-02-16 23:27:45 +0000 |
---|---|---|
committer | rustanleino <unknown> | 2011-02-16 23:27:45 +0000 |
commit | 94025aeed7bffe21b5be543c63dce7e9b255fce5 (patch) | |
tree | 9517f715f568cd584bcb28ebc003f6dfe50f323a /Test/dafny1/ExtensibleArray.dfy | |
parent | 79319c49d31f844b57c65c5adc7755ca788af7a6 (diff) |
Dafny: added test harness to Test/dafny1/ExtensibleArray.dfy
Diffstat (limited to 'Test/dafny1/ExtensibleArray.dfy')
-rw-r--r-- | Test/dafny1/ExtensibleArray.dfy | 22 |
1 files changed, 21 insertions, 1 deletions
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";
+}
|