-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add regression test for issue #1505 * Fix encoding of signed integer divisions
- Loading branch information
Showing
4 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
prusti-tests/tests/verify_overflow/fail/issues/issue-1505.rs
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,57 @@ | ||
use prusti_contracts::*; | ||
|
||
// To inhibit constant-propagation optimizations: | ||
#[pure] | ||
fn id<T: Copy>(x: T) -> T { x } | ||
|
||
fn check_division(){ | ||
assert!(id(3i32) / 2 == 1); | ||
assert!(id(-3i32) / 2 == -1); | ||
assert!(id(3i32) / -2 == -1); | ||
assert!(id(-3i32) / -2 == 1); | ||
prusti_assert!(id(3i32) / 2 == 1); | ||
prusti_assert!(id(-3i32) / 2 == -1); | ||
prusti_assert!(id(3i32) / -2 == -1); | ||
prusti_assert!(id(-3i32) / -2 == 1); | ||
|
||
// Smoke test | ||
assert!(false); //~ ERROR the asserted expression might not hold | ||
} | ||
|
||
fn check_modulo() { | ||
assert!(id(10) % 3 == 1); | ||
assert!(id(10) % -3 == 1); | ||
assert!(id(-10) % 3 == -1); | ||
assert!(id(-10) % -3 == -1); | ||
prusti_assert!(id(10) % 3 == 1); | ||
prusti_assert!(id(10) % -3 == 1); | ||
prusti_assert!(id(-10) % 3 == -1); | ||
prusti_assert!(id(-10) % -3 == -1); | ||
|
||
assert!(id(3) % 3 == 0); | ||
assert!(id(2) % 3 == 2); | ||
assert!(id(1) % 3 == 1); | ||
assert!(id(0) % 3 == 0); | ||
assert!(id(-1) % 3 == -1); | ||
assert!(id(-2) % 3 == -2); | ||
assert!(id(-3) % 3 == 0); | ||
assert!(id(-4) % 3 == -1); | ||
assert!(id(-5) % 3 == -2); | ||
prusti_assert!(id(3) % 3 == 0); | ||
prusti_assert!(id(2) % 3 == 2); | ||
prusti_assert!(id(1) % 3 == 1); | ||
prusti_assert!(id(0) % 3 == 0); | ||
prusti_assert!(id(-1) % 3 == -1); | ||
prusti_assert!(id(-2) % 3 == -2); | ||
prusti_assert!(id(-3) % 3 == 0); | ||
prusti_assert!(id(-4) % 3 == -1); | ||
prusti_assert!(id(-5) % 3 == -2); | ||
|
||
assert!(id(-4) % 2 == 0); | ||
prusti_assert!(id(-4) % 2 == 0); | ||
|
||
// Smoke test | ||
assert!(false); //~ ERROR the asserted expression might not hold | ||
} | ||
|
||
fn main(){} |
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