-
Notifications
You must be signed in to change notification settings - Fork 92
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
8f6eb3e
commit 5057572
Showing
8 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
tests/expected/function-contract/history/clone_fail.expected
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,11 @@ | ||
error[E0382]: borrow of moved value: `ptr` | ||
value borrowed here after move\ | ||
move occurs because `ptr` has type `&mut NoCopy<u32>`, which does not implement the `Copy` trait | ||
|
||
error[E0382]: borrow of moved value: `ptr` | ||
#[kani::ensures(old(ptr).0 + 1 == ptr.0)]\ | ||
value moved here | ||
#[kani::modifies(&mut ptr.0)]\ | ||
value borrowed here after move\ | ||
fn modify(ptr: &mut NoCopy<u32>) {\ | ||
move occurs because `ptr` has type `&mut NoCopy<u32>`, which does not implement the `Copy` trait |
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,24 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
struct NoCopy<T>(T); | ||
|
||
impl<T: kani::Arbitrary> kani::Arbitrary for NoCopy<T> { | ||
fn any() -> Self { | ||
Self(kani::any()) | ||
} | ||
} | ||
|
||
#[kani::ensures(old(ptr).0 + 1 == ptr.0)] | ||
#[kani::requires(ptr.0 < 100)] | ||
#[kani::modifies(&mut ptr.0)] | ||
fn modify(ptr: &mut NoCopy<u32>) { | ||
ptr.0 += 1; | ||
} | ||
|
||
#[kani::proof_for_contract(modify)] | ||
fn main() { | ||
let mut i = kani::any(); | ||
modify(&mut i); | ||
} |
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 @@ | ||
VERIFICATION:- SUCCESSFUL |
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,25 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
#[derive(Clone)] | ||
struct NoCopy<T>(T); | ||
|
||
impl<T: kani::Arbitrary> kani::Arbitrary for NoCopy<T> { | ||
fn any() -> Self { | ||
Self(kani::any()) | ||
} | ||
} | ||
|
||
#[kani::ensures(old(ptr.clone()).0 + 1 == ptr.0)] | ||
#[kani::requires(ptr.0 < 100)] | ||
#[kani::modifies(&mut ptr.0)] | ||
fn modify(ptr: &mut NoCopy<u32>) { | ||
ptr.0 += 1; | ||
} | ||
|
||
#[kani::proof_for_contract(modify)] | ||
fn main() { | ||
let mut i = kani::any(); | ||
modify(&mut i); | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/expected/function-contract/history/simple_fail.expected
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,7 @@ | ||
assertion\ | ||
- Status: FAILURE\ | ||
- Description: "old(*ptr) == *ptr" | ||
|
||
Failed Checks: old(*ptr) == *ptr | ||
|
||
VERIFICATION:- FAILED |
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,16 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
#[kani::ensures(old(*ptr) == *ptr)] | ||
#[kani::requires(*ptr < 100)] | ||
#[kani::modifies(ptr)] | ||
fn modify(ptr: &mut u32) { | ||
*ptr += 1; | ||
} | ||
|
||
#[kani::proof_for_contract(modify)] | ||
fn main() { | ||
let mut i = kani::any(); | ||
modify(&mut i); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/expected/function-contract/history/simple_pass.expected
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,5 @@ | ||
assertion\ | ||
- Status: SUCCESS\ | ||
- Description: "old(*ptr + 1) == *ptr"\ | ||
|
||
VERIFICATION:- SUCCESSFUL |
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,16 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
#[kani::ensures(old(*ptr + 1) == *ptr)] | ||
#[kani::requires(*ptr < 100)] | ||
#[kani::modifies(ptr)] | ||
fn modify(ptr: &mut u32) { | ||
*ptr += 1; | ||
} | ||
|
||
#[kani::proof_for_contract(modify)] | ||
fn main() { | ||
let mut i = kani::any(); | ||
modify(&mut i); | ||
} |