-
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.
Hack quantifier generation for complex types
- Loading branch information
Showing
3 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
prusti-tests/tests/verify/fail/native/structure_quantifiers.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,30 @@ | ||
// compile-flags: -Pviper_backend=Lithium | ||
use prusti_contracts::*; | ||
|
||
pub struct MyStructure {} | ||
|
||
impl MyStructure { | ||
#[pure] | ||
#[terminates] | ||
#[ensures (0 <= result)] | ||
pub fn len(&self) -> i32 { | ||
17 | ||
} | ||
} | ||
|
||
#[pure] | ||
#[terminates] | ||
#[ensures (0 <= result)] | ||
#[ensures(result == s.len())] | ||
fn len_of(s: &MyStructure) -> i32 { | ||
17 | ||
} | ||
|
||
#[ensures(forall(|s: MyStructure| s.len() == 3))] //~ ERROR postcondition might not hold | ||
fn test1(min: i32) {} | ||
|
||
#[ensures(forall(|s: MyStructure| len_of(&s) >= 17))] | ||
#[ensures(forall(|s: MyStructure| len_of(&s) >= 18))] //~ ERROR postcondition might not hold | ||
fn test2(min: i32) {} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
prusti-tests/tests/verify/pass/native/structure_quantifiers.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,27 @@ | ||
// compile-flags: -Pviper_backend=Lithium | ||
use prusti_contracts::*; | ||
|
||
pub struct MyStructure {} | ||
|
||
impl MyStructure { | ||
#[pure] | ||
#[terminates] | ||
#[ensures (0 <= result)] | ||
pub fn len(&self) -> i32 { | ||
17 | ||
} | ||
} | ||
|
||
#[pure] | ||
#[terminates] | ||
#[ensures (0 <= result)] | ||
#[ensures(result == s.len())] | ||
fn len_of(s: &MyStructure) -> i32 { | ||
17 | ||
} | ||
|
||
#[ensures(forall(|s: MyStructure| len_of(&s) >= 0))] | ||
#[ensures(forall(|s: MyStructure| s.len() >= 10))] | ||
fn test(min: i32) {} | ||
|
||
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