-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support 'require' and 'ensuring' message overloads
- Loading branch information
1 parent
87b66ff
commit 4422f93
Showing
7 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
frontends/benchmarks/verification/valid/RequireEnsuringMessages.scala
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,15 @@ | ||
object RequireEnsuringMessages { | ||
case class MyClass(a: Int) { | ||
require(a > 0, "a must be strictly positive") | ||
} | ||
|
||
def useMyClass(mc: MyClass): Int = { | ||
assert(mc.a > 0, "a is surely strictly positive") | ||
mc.a | ||
}.ensuring(_ > -42, "trivially trivial") | ||
|
||
def createMyClass(a: Int): MyClass = { | ||
require(a > 0, "To create MyClass, a must be strictly positive") | ||
MyClass(a) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
frontends/benchmarks/verification/valid/RequireEnsuringMessagesStaticChecks.scala
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 @@ | ||
import stainless.lang.StaticChecks._ | ||
|
||
object RequireEnsuringMessages { | ||
case class MyClass(a: Int) { | ||
require(a > 0, "a must be strictly positive") | ||
} | ||
|
||
def useMyClass(mc: MyClass): Int = { | ||
assert(mc.a > 0, "a is surely strictly positive") | ||
mc.a | ||
}.ensuring(_ > -42, "trivially trivial") | ||
|
||
def createMyClass(a: Int): MyClass = { | ||
require(a > 0, "To create MyClass, a must be strictly positive") | ||
MyClass(a) | ||
} | ||
} |
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