Skip to content

Commit

Permalink
Finish polishing contracts and create expected
Browse files Browse the repository at this point in the history
  • Loading branch information
celinval committed May 14, 2024
1 parent e844934 commit 7469d61
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions tests/std-checks/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ description = "This crate contains contracts and harnesses for core library"

[package.metadata.kani]
unstable = { function-contracts = true, mem-predicates = true }

[package.metadata.kani.flags]
output-format = "terse"
1 change: 0 additions & 1 deletion tests/std-checks/core/expected

This file was deleted.

3 changes: 3 additions & 0 deletions tests/std-checks/core/mem.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Summary:
Verification failed for - mem::verify::check_swap_unit
Complete - 3 successfully verified harnesses, 1 failures, 4 total.
3 changes: 3 additions & 0 deletions tests/std-checks/core/ptr.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Summary:
Verification failed for - ptr::verify::check_replace_unit
Complete - 5 successfully verified harnesses, 1 failures, 6 total.
4 changes: 4 additions & 0 deletions tests/std-checks/core/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ mod verify {
contracts::swap(&mut x, &mut y)
}

/// FIX-ME: Modifies clause fail with pointer to ZST.
/// <https://github.com/model-checking/kani/issues/3181>
/// FIX-ME: `typed_swap` intrisic fails for ZST.
/// <https://github.com/model-checking/kani/issues/3182>
#[kani::proof_for_contract(contracts::swap)]
pub fn check_swap_unit() {
let mut x: () = kani::any();
Expand Down
14 changes: 10 additions & 4 deletions tests/std-checks/core/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,22 @@ mod verify {

#[kani::proof_for_contract(contracts::as_ref)]
pub fn check_as_ref() {
let ptr = kani::any::<Box<usize>>();
let non_null = NonNull::new(Box::into_raw(ptr)).unwrap();
let _rf = unsafe { contracts::as_ref(&non_null) };
}

#[kani::proof_for_contract(contracts::as_ref)]
#[kani::should_panic]
pub fn check_as_ref_dangling() {
let ptr = kani::any::<usize>() as *mut u8;
kani::assume(!ptr.is_null());
let Some(non_null) = NonNull::new(ptr) else {
unreachable!();
};
let non_null = NonNull::new(ptr).unwrap();
let _rf = unsafe { contracts::as_ref(&non_null) };
}

/// FIX-ME: Modifies clause fail with pointer to ZST.
#[cfg(fixme)]
/// <https://github.com/model-checking/kani/issues/3181>
#[kani::proof_for_contract(contracts::replace)]
pub fn check_replace_unit() {
check_replace_impl::<()>();
Expand Down

0 comments on commit 7469d61

Please sign in to comment.