forked from viperproject/prusti-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28f4988
commit c906300
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
prusti-tests/tests/verify_partial/fail/issues/issue-729-1.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,33 @@ | ||
// error-pattern: Precondition of function snap$__$TY$__struct$m_A$Snap$struct$m_A might not hold | ||
// ^^^^^^^^^^^^^^ this is an actual assertion, see: | ||
// <https://rustc-dev-guide.rust-lang.org/tests/adding.html#when-error-line-cannot-be-specified> | ||
// FIXME: https://github.com/viperproject/prusti-dev/issues/729 | ||
#![allow(unused_comparisons)] | ||
extern crate prusti_contracts; | ||
use prusti_contracts::*; | ||
|
||
pub struct A { | ||
inner: [usize; 4], | ||
} | ||
|
||
impl A { | ||
#[pure] | ||
#[requires(index < self.inner.len())] | ||
pub fn is_valid(&self, index: usize) -> bool { | ||
self.inner[index] <= isize::MAX as usize | ||
} | ||
|
||
#[pure] | ||
#[ensures(forall(|i: usize| (result && index < self.inner.len() && 0 <= i && i <= index) ==> (self.is_valid(i))) )] | ||
pub fn test(&self, index: usize) -> bool { | ||
match index { | ||
index if 0 < index && index < self.inner.len() => { | ||
self.is_valid(index) && self.test(index - 1) | ||
} | ||
index if index == 0 => self.is_valid(index), | ||
_ => false, | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
29 changes: 29 additions & 0 deletions
29
prusti-tests/tests/verify_partial/fail/issues/issue-738-1.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,29 @@ | ||
use prusti_contracts::*; | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct A { | ||
count: isize, | ||
} | ||
|
||
impl A { | ||
#[pure] | ||
#[ensures(result <= isize::MAX as usize)] | ||
pub const fn len(&self) -> usize { | ||
if self.count < 0 { | ||
((1_isize + self.count) + isize::MAX) as usize | ||
} else { | ||
self.count as usize | ||
//~^ ERROR value might not fit into the target type. | ||
// FIXME: https://github.com/viperproject/prusti-dev/issues/738 | ||
} | ||
} | ||
} | ||
|
||
#[pure] | ||
#[requires(slice.len() > 0)] | ||
#[requires(slice[0].len() == 0)] | ||
pub fn test(slice: &[A]) -> bool { | ||
true | ||
} | ||
|
||
fn main() {} |