forked from viperproject/silver
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report branchconditions / FailureContext #1
Open
tschoesi
wants to merge
6
commits into
master
Choose a base branch
from
feature/report_branch_conditions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8bed69a
add FailureContext to Silver
tschoesi 6001a50
remove unneeded comment
tschoesi c7ae6e8
cosmetic changes
tschoesi 8be7f15
Revert "fix test annotations for carbon/issue/388"
tschoesi 53bd7a4
Revert "add UnexpectedOutput annotations"
tschoesi fc3f4a8
Revert "remove missingOutput annotation"
tschoesi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
field f: Int | ||
|
||
method test1(xs: Seq[Int]) | ||
//:: ExpectedOutput(not.wellformed:seq.index.negative) | ||
requires xs[-1] != 0 | ||
|
||
method test10(xs: Seq[Int]) | ||
//:: ExpectedOutput(not.wellformed:seq.index.length) | ||
ensures xs[1] != 0 | ||
|
||
method test2(xs: Seq[Int], n: Int) | ||
requires 5 < n | ||
//:: ExpectedOutput(not.wellformed:seq.index.length) | ||
requires forall i: Int :: i in [0..n) ==> xs[i] != 0 | ||
{ | ||
//:: UnexpectedOutput(assert.failed:seq.index.length, /Carbon/issue/388/) | ||
assert xs[3] != 0 | ||
} | ||
|
||
method test3(xs: Seq[Ref], n: Int) | ||
requires 5 < n && n < |xs| | ||
requires xs[0] != null | ||
requires forall i: Int :: i in [0..n) ==> acc(xs[i].f) | ||
{ | ||
var y: Int := xs[3].f | ||
} | ||
|
||
function fun(i: Int): Bool | ||
|
||
method test20(xs: Seq[Int], i: Int) { | ||
//:: ExpectedOutput(assignment.failed:seq.index.negative) | ||
//:: ExpectedOutput(assignment.failed:seq.index.length) | ||
var b: Bool := fun(xs[i]) | ||
} | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
field f: Int | ||
|
||
method test1(xs: Seq[Int]) | ||
//:: ExpectedOutput(not.wellformed:seq.index.negative) | ||
requires xs[-1] != 0 | ||
|
||
method test10(xs: Seq[Int]) | ||
//:: ExpectedOutput(not.wellformed:seq.index.length) | ||
ensures xs[1] != 0 | ||
|
||
method test2(xs: Seq[Int], n: Int) | ||
requires 5 < n | ||
//:: ExpectedOutput(not.wellformed:seq.index.length) | ||
requires forall i: Int :: i in [0..n) ==> xs[i] != 0 | ||
{ | ||
//:: ExpectedOutput(assert.failed:seq.index.length) | ||
//:: MissingOutput(assert.failed:seq.index.length, /silicon/issue/34/) | ||
assert xs[3] != 0 | ||
} | ||
|
||
method test3(xs: Seq[Ref], n: Int) | ||
requires 5 < n && n < |xs| | ||
requires xs[0] != null | ||
requires forall i: Int :: i in [0..n) ==> acc(xs[i].f) | ||
{ | ||
var y: Int := xs[3].f | ||
} | ||
|
||
function fun(i: Int): Bool | ||
|
||
method test20(xs: Seq[Int], i: Int) { | ||
//:: ExpectedOutput(assignment.failed:seq.index.negative) | ||
//:: ExpectedOutput(assignment.failed:seq.index.length) | ||
//:: MissingOutput(assignment.failed:seq.index.length, /silicon/issue/34/) | ||
var b: Bool := fun(xs[i]) | ||
} |
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 |
---|---|---|
@@ -1,112 +1,111 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
//:: IgnoreFile(/carbon/issue/216/) | ||
field f: Int | ||
|
||
define injectiveSeq(xs) forall i: Int, j: Int :: 0 <= i && 0 <= j && i < |xs| && j < |xs| && i != j ==> xs[i] != xs[j] | ||
|
||
method test0(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(x.f) | ||
requires injectiveSeq(xs) | ||
requires |xs| >= 1 | ||
requires acc(y.f) { | ||
xs[0].f := 0 | ||
y.f := 1 | ||
label setupComplete | ||
var toGo: Seq[Ref] := xs | ||
var completed: Seq[Ref] := Seq() | ||
while (|toGo| != 0) | ||
invariant forall x: Ref :: x in completed ==> acc(y.f) --* acc(x.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
invariant forall i: Int, j: Int :: 0 <= i && 0 <= j && i < |toGo| && j < |toGo| && i != j ==> toGo[i] != toGo[j] | ||
invariant forall x: Ref :: x in toGo ==> acc(x.f) | ||
invariant xs == completed ++ toGo | ||
invariant forall x: Ref :: x in toGo ==> x.f == old[setupComplete](x.f) | ||
invariant acc(y.f) && y.f == 1 | ||
//:: UnexpectedOutput(invariant.not.preserved:assertion.false, /silicon/issue/311/) | ||
invariant forall x: Ref :: x in completed ==> | ||
applying (acc(y.f) --* acc(x.f) && acc(y.f) && y.f == old[lhs](y.f)) in | ||
x.f == old[setupComplete](x.f) { | ||
var localX: Ref := toGo[0] | ||
package acc(y.f) --* acc(localX.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
completed := completed ++ Seq(localX) | ||
toGo := toGo[1..] | ||
} | ||
assert forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
var some: Ref := xs[0] | ||
apply acc(y.f) --* acc(some.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
//:: UnexpectedOutput(assert.failed:assertion.false, /silicon/issue/551/) | ||
assert some.f == 0 //This shouldn't throw an error | ||
assert y.f == 1 | ||
} | ||
|
||
method test1(x: Ref) | ||
requires forall i: Int :: true ==> acc(x.f) && x.f == i --* acc(x.f) { | ||
exhale forall i: Int :: true ==> acc(x.f) && x.f == i-1 --* acc(x.f) | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall i: Int :: true ==> acc(x.f) && x.f == i --* acc(x.f) | ||
} | ||
|
||
method test2(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) { | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall x: Ref :: x in xs ==> acc(y.f) --* acc(y.f) && acc(x.f) | ||
} | ||
|
||
method test3(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
requires injectiveSeq(xs) | ||
requires |xs| > 0 | ||
requires acc(y.f) { | ||
var some: Ref := xs[0] | ||
package true --* acc(some.f) && acc(y.f) { | ||
apply acc(y.f) --* acc(some.f) && acc(y.f) | ||
} | ||
assert forall x: Ref :: x in xs[1..] ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
} | ||
|
||
method test4(x: Ref) | ||
requires forall i: Int, j: Int :: true ==> acc(x.f) && x.f == i + j --* acc(x.f) { | ||
exhale acc(x.f) && x.f == 5 --* acc(x.f) | ||
assert forall i: Int :: i != 5 ==> acc(x.f) && x.f == i --* acc(x.f) | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall i: Int :: true ==> acc(x.f) && x.f == i --* acc(x.f) | ||
} | ||
|
||
method test5(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(x.f) | ||
requires injectiveSeq(xs) | ||
requires |xs| >= 1 | ||
requires acc(y.f) { | ||
xs[0].f := 0 | ||
y.f := 1 | ||
var some: Ref := xs[0] | ||
package acc(y.f) --* acc(some.f) && acc(y.f) | ||
var completed: Seq[Ref] := Seq(some) | ||
assert forall x: Ref :: x in completed ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
assert applying (acc(y.f) --* acc(some.f) && acc(y.f)) in some.f == 0 | ||
assert applying (acc(y.f) --* acc(some.f) && acc(y.f)) in y.f == 1 | ||
assert forall x: Ref :: x in xs[1..] ==> acc(x.f) | ||
|
||
//:: ExpectedOutput(assert.failed:insufficient.permission) | ||
assert forall x: Ref :: x in xs ==> acc(x.f) | ||
} | ||
|
||
method test6(xs: Seq[Ref]) | ||
requires forall x: Ref :: x in xs ==> true --* acc(x.f) | ||
requires |xs| > 0 { | ||
assume applying (true --* acc(xs[0].f)) in xs[0].f == 0 | ||
package true --* (forall x: Ref :: x in xs ==> true --* acc(x.f)) | ||
apply true --* (forall x: Ref :: x in xs ==> true --* acc(x.f)) | ||
apply true --* acc(xs[0].f) | ||
assert xs[0].f == 0 | ||
|
||
//:: ExpectedOutput(assert.failed:assertion.false) | ||
assert false | ||
} | ||
//:: IgnoreFile(/carbon/issue/216/) | ||
field f: Int | ||
|
||
define injectiveSeq(xs) forall i: Int, j: Int :: 0 <= i && 0 <= j && i < |xs| && j < |xs| && i != j ==> xs[i] != xs[j] | ||
|
||
method test0(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(x.f) | ||
requires injectiveSeq(xs) | ||
requires |xs| >= 1 | ||
requires acc(y.f) { | ||
xs[0].f := 0 | ||
y.f := 1 | ||
label setupComplete | ||
var toGo: Seq[Ref] := xs | ||
var completed: Seq[Ref] := Seq() | ||
while (|toGo| != 0) | ||
invariant forall x: Ref :: x in completed ==> acc(y.f) --* acc(x.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
invariant forall i: Int, j: Int :: 0 <= i && 0 <= j && i < |toGo| && j < |toGo| && i != j ==> toGo[i] != toGo[j] | ||
invariant forall x: Ref :: x in toGo ==> acc(x.f) | ||
invariant xs == completed ++ toGo | ||
invariant forall x: Ref :: x in toGo ==> x.f == old[setupComplete](x.f) | ||
invariant acc(y.f) && y.f == 1 | ||
//:: UnexpectedOutput(invariant.not.preserved:assertion.false, /silicon/issue/311/) | ||
invariant forall x: Ref :: x in completed ==> | ||
applying (acc(y.f) --* acc(x.f) && acc(y.f) && y.f == old[lhs](y.f)) in | ||
x.f == old[setupComplete](x.f) { | ||
var localX: Ref := toGo[0] | ||
package acc(y.f) --* acc(localX.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
completed := completed ++ Seq(localX) | ||
toGo := toGo[1..] | ||
} | ||
assert forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
var some: Ref := xs[0] | ||
apply acc(y.f) --* acc(some.f) && acc(y.f) && y.f == old[lhs](y.f) | ||
assert some.f == 0 | ||
assert y.f == 1 | ||
} | ||
|
||
method test1(x: Ref) | ||
requires forall i: Int :: true ==> acc(x.f) && x.f == i --* acc(x.f) { | ||
exhale forall i: Int :: true ==> acc(x.f) && x.f == i-1 --* acc(x.f) | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall i: Int :: true ==> acc(x.f) && x.f == i --* acc(x.f) | ||
} | ||
|
||
method test2(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) { | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall x: Ref :: x in xs ==> acc(y.f) --* acc(y.f) && acc(x.f) | ||
} | ||
|
||
method test3(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
requires injectiveSeq(xs) | ||
requires |xs| > 0 | ||
requires acc(y.f) { | ||
var some: Ref := xs[0] | ||
package true --* acc(some.f) && acc(y.f) { | ||
apply acc(y.f) --* acc(some.f) && acc(y.f) | ||
} | ||
assert forall x: Ref :: x in xs[1..] ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall x: Ref :: x in xs ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
} | ||
|
||
method test4(x: Ref) | ||
requires forall i: Int, j: Int :: true ==> acc(x.f) && x.f == i + j --* acc(x.f) { | ||
exhale acc(x.f) && x.f == 5 --* acc(x.f) | ||
assert forall i: Int :: i != 5 ==> acc(x.f) && x.f == i --* acc(x.f) | ||
|
||
//:: ExpectedOutput(assert.failed:wand.not.found) | ||
assert forall i: Int :: true ==> acc(x.f) && x.f == i --* acc(x.f) | ||
} | ||
|
||
method test5(xs: Seq[Ref], y: Ref) | ||
requires forall x: Ref :: x in xs ==> acc(x.f) | ||
requires injectiveSeq(xs) | ||
requires |xs| >= 1 | ||
requires acc(y.f) { | ||
xs[0].f := 0 | ||
y.f := 1 | ||
var some: Ref := xs[0] | ||
package acc(y.f) --* acc(some.f) && acc(y.f) | ||
var completed: Seq[Ref] := Seq(some) | ||
assert forall x: Ref :: x in completed ==> acc(y.f) --* acc(x.f) && acc(y.f) | ||
assert applying (acc(y.f) --* acc(some.f) && acc(y.f)) in some.f == 0 | ||
assert applying (acc(y.f) --* acc(some.f) && acc(y.f)) in y.f == 1 | ||
assert forall x: Ref :: x in xs[1..] ==> acc(x.f) | ||
|
||
//:: ExpectedOutput(assert.failed:insufficient.permission) | ||
assert forall x: Ref :: x in xs ==> acc(x.f) | ||
} | ||
|
||
method test6(xs: Seq[Ref]) | ||
requires forall x: Ref :: x in xs ==> true --* acc(x.f) | ||
requires |xs| > 0 { | ||
assume applying (true --* acc(xs[0].f)) in xs[0].f == 0 | ||
package true --* (forall x: Ref :: x in xs ==> true --* acc(x.f)) | ||
apply true --* (forall x: Ref :: x in xs ==> true --* acc(x.f)) | ||
apply true --* acc(xs[0].f) | ||
assert xs[0].f == 0 | ||
|
||
//:: ExpectedOutput(assert.failed:assertion.false) | ||
assert false | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline between trait declarations