-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from marcoeilers/abstract_predicates
Abstract predicates
- Loading branch information
Showing
9 changed files
with
150 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from nagini_contracts.contracts import * | ||
|
||
class MyClass: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
@Predicate | ||
@ContractOnly | ||
def huh(mc: MyClass) -> bool: | ||
return True | ||
|
||
@Pure | ||
def huhFunc(mc: MyClass) -> int: | ||
Requires(huh(mc)) | ||
Ensures(Result() > 0) | ||
#:: ExpectedOutput(invalid.program:abstract.predicate.fold) | ||
return Unfolding(huh(mc), 6) |
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,17 @@ | ||
from nagini_contracts.contracts import * | ||
|
||
class MyClass: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
@Predicate | ||
@ContractOnly | ||
def huh(mc: MyClass) -> bool: | ||
return True | ||
|
||
def huhFunc(mc: MyClass) -> int: | ||
Requires(huh(mc)) | ||
Ensures(Result() > 0) | ||
#:: ExpectedOutput(invalid.program:abstract.predicate.fold) | ||
Unfold(huh(mc)) | ||
return 3 |
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,16 @@ | ||
from nagini_contracts.contracts import * | ||
|
||
class MyClass: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
@Predicate | ||
@ContractOnly | ||
def huh(mc: MyClass) -> bool: | ||
return True | ||
|
||
def huhFunc(mc: MyClass) -> int: | ||
Ensures(Result() > 0) | ||
#:: ExpectedOutput(invalid.program:abstract.predicate.fold) | ||
Fold(huh(mc)) | ||
return 4 |
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,17 @@ | ||
from nagini_contracts.contracts import * | ||
|
||
class MyClass: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
@Predicate | ||
@ContractOnly | ||
def huh(self) -> bool: | ||
return True | ||
|
||
|
||
def huhFunc(mc: MyClass) -> int: | ||
Ensures(Result() > 0) | ||
#:: ExpectedOutput(invalid.program:abstract.predicate.fold) | ||
Fold(mc.huh()) | ||
return 4 |
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,19 @@ | ||
from nagini_contracts.contracts import * | ||
|
||
|
||
class MyClass: | ||
def __init__(self) -> None: | ||
self.x = 1 | ||
|
||
@Predicate | ||
@ContractOnly | ||
def myHuh(self) -> bool: | ||
return self.x > 2 | ||
|
||
|
||
class MySubClass(MyClass): | ||
|
||
@Predicate #:: ExpectedOutput(invalid.program:partially.abstract.predicate.family) | ||
def myHuh(self) -> bool: | ||
return self.x > 4 | ||
|
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,33 @@ | ||
from nagini_contracts.contracts import * | ||
|
||
|
||
class MyClass: | ||
def __init__(self) -> None: | ||
self.x = 1 | ||
|
||
@Predicate | ||
@ContractOnly | ||
def myHuh(self) -> bool: | ||
return self.x > 2 | ||
|
||
|
||
class MySubClass(MyClass): | ||
|
||
@Predicate | ||
@ContractOnly | ||
def myHuh(self) -> bool: | ||
return self.x > 4 | ||
|
||
|
||
@Predicate | ||
@ContractOnly | ||
def huh(mc: MyClass) -> bool: | ||
return mc.x > 6 | ||
|
||
|
||
@Pure | ||
@ContractOnly | ||
def huhFunc(mc: MyClass) -> int: | ||
Requires(huh(mc)) | ||
Ensures(Result() > 0) | ||
return Unfolding(huh(mc), 6) |