Skip to content

Commit

Permalink
Add regression test for issue #1505
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoli committed Mar 25, 2024
1 parent 528f4c2 commit 519ff34
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions prusti-tests/tests/verify_overflow/fail/issues/issue-1505.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use prusti_contracts::*;

// To inhibit constant-propagation optimizations:
#[pure]
fn id<T>(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);

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);

assert!(id(-4) % 2 == 0);

// Smoke test
assert!(false); //~ ERROR the asserted expression might not hold
}

fn main(){}

0 comments on commit 519ff34

Please sign in to comment.