From 3baf091750430d9f94cd75ac0334d54748f7a8c0 Mon Sep 17 00:00:00 2001 From: rustanleino Date: Wed, 16 Feb 2011 23:27:45 +0000 Subject: Dafny: added test harness to Test/dafny1/ExtensibleArray.dfy --- Test/dafny1/Answer | 2 +- Test/dafny1/ExtensibleArray.dfy | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'Test/dafny1') 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 { // there is room in "elements" elements[length - M] := t; } else { - if (length == 256) { + if (more == null) { var mr := new ExtensibleArray>; more := mr; call mr.Init(); Repr := Repr + {mr} + mr.Repr; @@ -106,3 +106,23 @@ class ExtensibleArray { Contents := Contents + [t]; } } + +method Main() { + var a := new ExtensibleArray; + 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"; +} -- cgit v1.2.3