-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
20 changed files
with
220 additions
and
25 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
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
39 changes: 39 additions & 0 deletions
39
src/test/resources/regressions/features/ghost_pointer/ghost-write-fail02.gobra
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,39 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package GhostWriteFail02 | ||
|
||
// this testcase checks that an actual method cannot be called within ghost code as this method might modify | ||
// non-ghost memory. | ||
|
||
decreases | ||
requires acc(x) | ||
func foo(x *int) { | ||
*x = 0 | ||
} | ||
|
||
ghost | ||
decreases | ||
requires acc(x) | ||
func bar(x *int) { | ||
// the following two calls are type-checked in the same way as we are already in a ghost context. | ||
// each call technically results in two type errors, i.e., (1) calling a non-ghost method in a ghost context and | ||
// (2) assigning a ghost variable `x` to a non-ghost parameter. | ||
|
||
//:: ExpectedOutput(type_error) | ||
ghost foo(x) | ||
|
||
//:: ExpectedOutput(type_error) | ||
foo(x) | ||
} | ||
|
||
decreases | ||
requires acc(x) | ||
func bar2(x *int) { | ||
// the following call fails because we call a non-ghost method in a ghost context: | ||
//:: ExpectedOutput(type_error) | ||
ghost foo(x) | ||
|
||
// this is fine since we are in a non-ghost context: | ||
foo(x) | ||
} |
65 changes: 65 additions & 0 deletions
65
src/test/resources/regressions/features/interfaces/ghostnessOfImplementation-fail1.gobra
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,65 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
// this test makes sure that a method's implementation has the same ghostness as specified in the interface | ||
|
||
package pkg | ||
|
||
type itfWithActualMethod interface { | ||
decreases | ||
actualMethod() int | ||
} | ||
|
||
type itfWithActualPureMethod interface { | ||
decreases | ||
pure actualPureMethod() int | ||
} | ||
|
||
type itfWithGhostMethod interface { | ||
ghost | ||
decreases | ||
ghostMethod() int | ||
} | ||
|
||
type itfWithGhostPureMethod interface { | ||
ghost | ||
decreases | ||
pure ghostPureMethod() int | ||
} | ||
|
||
type someImplementation struct { | ||
value int | ||
} | ||
|
||
// checks that `someImplementation` is indeed considered an implementation of each interface, i.e., that the ghost | ||
// attribute in the interface and implementation is correctly handled. | ||
//:: ExpectedOutput(type_error) | ||
*someImplementation implements itfWithActualMethod | ||
//:: ExpectedOutput(type_error) | ||
*someImplementation implements itfWithActualPureMethod | ||
//:: ExpectedOutput(type_error) | ||
*someImplementation implements itfWithGhostMethod | ||
//:: ExpectedOutput(type_error) | ||
*someImplementation implements itfWithGhostPureMethod | ||
|
||
ghost | ||
decreases | ||
func (impl *someImplementation) actualMethod() int { | ||
return 42 | ||
} | ||
|
||
ghost | ||
decreases | ||
pure func (impl *someImplementation) actualPureMethod() int { | ||
return 42 | ||
} | ||
|
||
decreases | ||
func (impl *someImplementation) ghostMethod() int { | ||
return 42 | ||
} | ||
|
||
decreases | ||
pure func (impl *someImplementation) ghostPureMethod() int { | ||
return 42 | ||
} |
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
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,29 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package main | ||
|
||
ghost | ||
decreases x | ||
pure func more(x int) int { | ||
return x <= 0 ? 1 : more(x - 2) + 3 | ||
} | ||
|
||
ghost /* lemma */ | ||
decreases x | ||
ensures x < more(x) | ||
func increasing(x int) | ||
|
||
// returning b (a ghost variable) is not allowed as this is an actual function | ||
//:: ExpectedOutput(type_error) | ||
func exampleLemmaUse(a int) int { | ||
increasing(a) | ||
b := more(a) | ||
c := more(b) | ||
if a < 1000 { | ||
increasing(more(a)) | ||
assert 2 <= c - a | ||
} | ||
assert 2 <= c - a || 200 <= a | ||
return b | ||
} |
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