diff options
author | Michael Lowell Roberts <mirobert@microsoft.com> | 2015-07-08 11:01:11 -0700 |
---|---|---|
committer | Michael Lowell Roberts <mirobert@microsoft.com> | 2015-07-08 11:01:11 -0700 |
commit | fad74b96e5d9367960358b1c4cc9c2cce79e961a (patch) | |
tree | 805771f13c38cc2206ee9f6d6226651db5b61573 /Test/irondafny0/LIFO.dfy | |
parent | 85d4456ccf1e1d8c456dffa012d3f3d724f50a4a (diff) |
added unit tests for exclusive refinement.
Diffstat (limited to 'Test/irondafny0/LIFO.dfy')
-rw-r--r-- | Test/irondafny0/LIFO.dfy | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Test/irondafny0/LIFO.dfy b/Test/irondafny0/LIFO.dfy new file mode 100644 index 00000000..bac08fba --- /dev/null +++ b/Test/irondafny0/LIFO.dfy @@ -0,0 +1,43 @@ +// RUN: %dafny /compile:3 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+include "Queue.dfyi"
+
+module LIFO exclusively refines Queue {
+ type Item = int
+
+ method Init() returns (q: Queue) {
+ q := [];
+ }
+
+ method Push(item: Item, q: Queue) returns (q': Queue) {
+ return [item] + q;
+ }
+
+ method Pop(q: Queue) returns (item: Item, q': Queue)
+ ensures item == q[0]
+ {
+ item := q[0];
+ q' := q[1..];
+ }
+}
+
+module MainImpl refines MainSpec {
+ import Q = LIFO
+
+ method Main()
+ {
+ var q := Q.Init();
+ q := Q.Push(0, q);
+ q := Q.Push(1, q);
+ q := Q.Push(2, q);
+
+ var n: int;
+ n, q := Q.Pop(q);
+ print n, "\n";
+ n, q := Q.Pop(q);
+ print n, "\n";
+ n, q := Q.Pop(q);
+ print n, "\n";
+ }
+}
|