-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
field f: Int | ||
|
||
predicate P(x: Ref) { acc(x.f, wildcard) } | ||
|
||
method test40(x: Ref, y: Ref) | ||
requires acc(x.f, 1/2) && acc(y.f, 1/2) | ||
{ | ||
fold P(x) | ||
exhale acc(x.f, perm(x.f)) | ||
exhale acc(y.f, perm(y.f)) | ||
unfold P(x) | ||
if (y == x) { | ||
assert y.f == old(y.f) | ||
} | ||
} | ||
|
||
method test50(x: Ref, y: Ref) | ||
{ | ||
inhale acc(P(x), 1/2) && acc(P(y), 1/2) | ||
//:: ExpectedOutput(exhale.failed:insufficient.permission) | ||
exhale acc(P(x), wildcard) && acc(P(y), 1/2) | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/resources/viperDebugger/predicateUnfoldingWithRef.vpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
field val : Int | ||
|
||
|
||
predicate greater0(n : Ref, p : Perm) | ||
{ | ||
none < p && p <= write && acc(n.val, p) && n.val >= 0 | ||
} | ||
|
||
method my_unfold(n : Ref) | ||
requires acc(n.val, 1/2) && greater0(n, 1/2) | ||
ensures acc(n.val, 1/2) && n.val >= 0 | ||
{ | ||
assert unfolding greater0(n, 1/2) in n.val >= 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
|
||
method test_sequence() | ||
{ | ||
var s : Seq[Int] | ||
s := Seq(1,3,3) | ||
var z : Int | ||
z := s[1] + s[2] | ||
assert z == 6 | ||
} | ||
|
||
method test_sequence_append(s1 : Seq[Int], s2: Seq[Int]) | ||
requires |s1| > 0 && |s2| > 0 | ||
{ | ||
var s : Seq[Int] | ||
s := s1 ++ s2 | ||
assert |s| > 1 | ||
} |