|
| 1 | +use prusti_contracts::*; |
| 2 | + |
| 3 | +// To inhibit constant-propagation optimizations: |
| 4 | +#[pure] |
| 5 | +fn id<T>(x: T) -> T { x} |
| 6 | + |
| 7 | +fn check_division(){ |
| 8 | + assert!(id(3i32) / 2 == 1); |
| 9 | + assert!(id(-3i32) / 2 == -1); |
| 10 | + assert!(id(3i32) / -2 == -1); |
| 11 | + assert!(id(-3i32) / -2 == 1); |
| 12 | + prusti_assert!(id(3i32) / 2 == 1); |
| 13 | + prusti_assert!(id(-3i32) / 2 == -1); |
| 14 | + prusti_assert!(id(3i32) / -2 == -1); |
| 15 | + prusti_assert!(id(-3i32) / -2 == 1); |
| 16 | + |
| 17 | + // Smoke test |
| 18 | + assert!(false); //~ ERROR the asserted expression might not hold |
| 19 | +} |
| 20 | + |
| 21 | +fn check_modulo() { |
| 22 | + assert!(id(10) % 3 == 1); |
| 23 | + assert!(id(10) % -3 == 1); |
| 24 | + assert!(id(-10) % 3 == -1); |
| 25 | + assert!(id(-10) % -3 == -1); |
| 26 | + |
| 27 | + assert!(id(3) % 3 == 0); |
| 28 | + assert!(id(2) % 3 == 2); |
| 29 | + assert!(id(1) % 3 == 1); |
| 30 | + assert!(id(0) % 3 == 0); |
| 31 | + assert!(id(-1) % 3 == -1); |
| 32 | + assert!(id(-2) % 3 == -2); |
| 33 | + assert!(id(-3) % 3 == 0); |
| 34 | + assert!(id(-4) % 3 == -1); |
| 35 | + assert!(id(-5) % 3 == -2); |
| 36 | + |
| 37 | + assert!(id(-4) % 2 == 0); |
| 38 | + |
| 39 | + // Smoke test |
| 40 | + assert!(false); //~ ERROR the asserted expression might not hold |
| 41 | +} |
| 42 | + |
| 43 | +fn main(){} |
0 commit comments