-
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 a test for the 878 and a to-be-supported one
- Loading branch information
1 parent
dfbba66
commit 98b6668
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
prusti-tests/tests/verify_overflow/pass/issues/issue-878.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,18 @@ | ||
use prusti_contracts::*; | ||
use std::cmp::{Ord, Ordering}; | ||
fn main() {} | ||
|
||
#[extern_spec] | ||
trait Ord { | ||
#[pure] | ||
fn cmp(&self, other: &Self) -> Ordering; | ||
} | ||
|
||
#[pure] | ||
pub fn eq<T: Ord>(a: &T, b: &T) -> bool { | ||
match a.cmp(b) { | ||
Ordering::Equal => true, | ||
Ordering::Less => false, | ||
Ordering::Greater => false, | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
prusti-tests/tests/verify_overflow/pass/quantifiers/generics.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,41 @@ | ||
// The client code still causes crashes: | ||
// ignore-test | ||
use prusti_contracts::*; | ||
use std::cmp::{Ord, Ordering::{self, Equal, Less}}; | ||
fn main() { | ||
let mut v = 42; | ||
client(&mut v, true); | ||
} | ||
|
||
#[pure] | ||
fn tautology<T>(_arg: &T, _arg2: &T) -> bool { true } | ||
|
||
#[requires(forall(|other: &T| tautology(&x, other)))] | ||
#[ensures(forall(|other: T| tautology(&other, &result)))] | ||
fn foo<T>(x: T) -> T { x } | ||
|
||
#[extern_spec] | ||
trait Ord { | ||
#[pure] | ||
fn cmp(&self, other: &Self) -> Ordering; | ||
} | ||
|
||
#[requires(forall(|other: &T| | ||
matches!(_lower.cmp(other), Less) | ||
&& matches!(other.cmp(_upper), Less) | ||
==> matches!(_only_middle.cmp(other), Equal)))] | ||
fn bar<T: Ord>(_lower: &T, _only_middle: &T, _upper: &T) { } | ||
|
||
fn client<U: Ord, T: Ord + Copy>(x1: U, y1: T) { | ||
let x2 = foo(x1); | ||
bar(&x2, &x2, &x2); | ||
|
||
let y2 = foo(y1); | ||
let y3 = y2; | ||
bar(&y2, &y1, &y3); | ||
|
||
let val1 = 10; | ||
let val2 = foo(val1); | ||
let val3 = val1; | ||
bar(&val1, &val3, &val2); | ||
} |