diff options
author | Christian Klauser <sealedsun@gmail.com> | 2012-03-27 14:20:18 +0200 |
---|---|---|
committer | Christian Klauser <sealedsun@gmail.com> | 2012-03-27 14:20:18 +0200 |
commit | eb1bb14630dfebb38322ed1841b0cfd50827c122 (patch) | |
tree | 87f27ba509e3c07aa957daa71b8c5780f8e175a0 /Test/dafny0/Refinement.dfy | |
parent | 3b45b6e751b6dd8f45a88f1c3ed909f3917f6083 (diff) | |
parent | 62045c2517dd51f54e40dcfb783fc1370eced93c (diff) |
Merge
Diffstat (limited to 'Test/dafny0/Refinement.dfy')
-rw-r--r-- | Test/dafny0/Refinement.dfy | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/Test/dafny0/Refinement.dfy b/Test/dafny0/Refinement.dfy index 280227f1..da7f0ac2 100644 --- a/Test/dafny0/Refinement.dfy +++ b/Test/dafny0/Refinement.dfy @@ -25,7 +25,7 @@ module B refines A { } method M(x: int) returns (y: int) ensures y % 2 == 0; // add a postcondition - method Q() returns (q: int, r: int, s: int) + method Q ... ensures 12 <= r; ensures 1200 <= s; // error: postcondition is not established by // inherited method body @@ -44,7 +44,7 @@ module A_AnonymousClass { } module B_AnonymousClass refines A_AnonymousClass { - method Increment(d: int) + method Increment... ensures x <= old(x) + d; } @@ -96,10 +96,10 @@ module FullBodied refines BodyFree { } // ------------------------------------------------ -/* SOON + module Abstract { class MyNumber { - var N: int; + ghost var N: int; ghost var Repr: set<object>; predicate Valid reads this, Repr; @@ -125,7 +125,8 @@ module Abstract { requires Valid; ensures n == N; { - n := N; + var k; assume k == N; + n := k; } } } @@ -148,7 +149,8 @@ module Concrete refines Abstract { } method Get() returns (n: int) { - n := a - b; + var k := a - b; + assert ...; } } } @@ -164,4 +166,27 @@ module Client imports Concrete { } } } -*/ + +module IncorrectConcrete refines Abstract { + class MyNumber { + var a: int; + var b: int; + predicate Valid + { + N == 2*a - b + } + constructor Init() + { // error: postcondition violation + a := b; + } + method Inc() + { // error: postcondition violation + if (*) { a := a + 1; } else { b := b - 1; } + } + method Get() returns (n: int) + { + var k := a - b; + assert ...; // error: assertion violation + } + } +} |