-
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.
Tests, outputting warnings when uninterpreted floats are used
- Loading branch information
1 parent
bcf5ec7
commit 523447e
Showing
7 changed files
with
157 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Any copyright is dedicated to the Public Domain. | ||
# http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
#:: IgnoreFile(carbon)(158) | ||
|
||
from nagini_contracts.contracts import * | ||
|
||
def useOps(f: float, g: float) -> float: | ||
a = f - g | ||
b = f * g | ||
c = f > g | ||
d = f >= g | ||
e = f < g | ||
e2 = f <= g | ||
return f | ||
|
||
|
||
def cmpLits() -> None: | ||
Assert(3.0 > 2.0) | ||
Assert(1.0 <= 40.0) | ||
|
||
def sqr3(num : float) -> float: | ||
Requires(num >= 0.0) | ||
#:: ExpectedOutput(postcondition.violated:assertion.false) | ||
Ensures(Result() > 0.0) | ||
Ensures(num * num == Result()) | ||
return num * num | ||
|
||
def arith(num: float) -> float: | ||
Requires(num == num) # not NaN | ||
Ensures(Result() == num + 3.0) | ||
tmp = 1.0 + 2.0 | ||
return num + tmp | ||
|
||
|
||
def arith3(num: float) -> float: | ||
#:: ExpectedOutput(postcondition.violated:assertion.false) | ||
Ensures(Result() == num + 3.0) | ||
return num + 3.0 | ||
|
||
|
||
def arith2(num: float) -> float: | ||
Requires(num == num) # not NaN | ||
#:: ExpectedOutput(postcondition.violated:assertion.false) | ||
Ensures(Result() == num + 4.0) | ||
return num + 1.0 + 2.0 | ||
|
||
|
||
def intComp() -> None: | ||
a = 3.0 | ||
b = 3 | ||
#:: UnexpectedOutput(assert.failed:assertion.false,158) | ||
Assert(a == b) | ||
|
||
def divSave(f: float, g: float) -> float: | ||
#:: ExpectedOutput(application.precondition:assertion.false) | ||
return f / g | ||
|
||
def divSave2(f: float, g: float) -> float: | ||
Requires(g != 0.0) | ||
return f / g |
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,66 @@ | ||
# Any copyright is dedicated to the Public Domain. | ||
# http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
|
||
from nagini_contracts.contracts import * | ||
|
||
|
||
def useOps(f: float, g: float) -> float: | ||
a = f - g | ||
b = f * g | ||
c = f > g | ||
d = f >= g | ||
e = f < g | ||
e2 = f <= g | ||
return f | ||
|
||
|
||
def cmpLits() -> None: | ||
Assert(3.0 > 2.0) | ||
Assert(1.0 <= 40.0) | ||
|
||
def sqr(num : float) -> float: | ||
Requires(num >= 0) | ||
Ensures(Result() >= 0) | ||
Ensures(num * num == Result()) | ||
return num * num | ||
|
||
|
||
def sqr2(num : float) -> float: | ||
Requires(num >= 0.0) | ||
Ensures(Result() >= 0.0) | ||
Ensures(num * num == Result()) | ||
return num * num | ||
|
||
|
||
def sqr3(num : float) -> float: | ||
Requires(num >= 0.0) | ||
#:: ExpectedOutput(postcondition.violated:assertion.false) | ||
Ensures(Result() > 0.0) | ||
Ensures(num * num == Result()) | ||
return num * num | ||
|
||
def arith(num: float) -> float: | ||
Ensures(Result() == num + 3) | ||
return num + 1.0 + 2.0 | ||
|
||
|
||
def arith2(num: float) -> float: | ||
#:: ExpectedOutput(postcondition.violated:assertion.false) | ||
Ensures(Result() == num + 4) | ||
return num + 1.0 + 2.0 | ||
|
||
|
||
def intComp() -> None: | ||
a = 3.0 | ||
b = 3 | ||
Assert(a == b) | ||
|
||
def divSave(f: float, g: float) -> float: | ||
#:: ExpectedOutput(application.precondition:assertion.false) | ||
tmp = f / g | ||
return 1.0 | ||
|
||
def divSave2(f: float, g: float) -> float: | ||
Requires(g != 0.0) | ||
return f / g |