-
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
Showing
7 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
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
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 @@ | ||
| | ||
| #[kani::requires(a + b)] | ||
| -----------------^^^^^-- | ||
| | | | ||
| | expected `bool`, found `u64` | ||
| arguments to this function are incorrect | ||
| | ||
|
||
| | ||
| #[kani::ensures(|result| a % *result && b % *result == 0 && *result != 0)] | ||
| ^^^^^^^^^^^ expected `bool`, found `u64` |
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,13 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
// This tests that Kani reports the "ideal" error message when contracts are non-boolean expressions | ||
// By "ideal," we mean that the error spans are as narrow as possible | ||
// (c.f. https://github.com/model-checking/kani/issues/3009) | ||
|
||
#[kani::requires(a + b)] | ||
#[kani::ensures(|result| a % *result && b % *result == 0 && *result != 0)] | ||
fn gcd(a: u64, b: u64) -> u64 { | ||
0 | ||
} |
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,17 @@ | ||
error: only one '#[kani::proof_for_contract]' attribute is allowed per harness\ | ||
invalid.rs:\ | ||
|\ | ||
| #[kani::proof_for_contract(foo)]\ | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: functions used as harnesses cannot have any arguments\ | ||
invalid.rs:\ | ||
|\ | ||
| #[kani::proof_for_contract(foo)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: the '#[kani::proof_for_contract]' attribute cannot be applied to generic functions\ | ||
invalid.rs:\ | ||
|\ | ||
| #[kani::proof_for_contract(foo)]\ | ||
| ^^^^^^^^^^^^^^ |
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 | ||
|
||
// This test is to check Kani's error handling of invalid usages of the `proof_for_contract` harness. | ||
// We also ensure that all errors and warnings are printed in one compilation. | ||
|
||
#[kani::requires(true)] | ||
fn foo() {} | ||
|
||
#[kani::proof_for_contract(foo)] | ||
#[kani::proof_for_contract(foo)] | ||
fn multiple_proof_annotations() { | ||
foo(); | ||
} | ||
|
||
#[kani::proof_for_contract(foo)] | ||
fn proof_with_arg(arg: bool) { | ||
foo(); | ||
} | ||
|
||
#[kani::proof_for_contract(foo)] | ||
fn generic_harness<T: Default>() { | ||
foo(); | ||
} |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
error: the `proof` attribute cannot be applied to generic functions | ||
error: the '#[kani::proof]' attribute cannot be applied to generic functions |