-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic warning and add arbitrary Duration (#2820)
Add an Arbitrary implementation for Duration and also fix unused variable warnings when panic message uses a variable in its format string.
- Loading branch information
Showing
8 changed files
with
90 additions
and
2 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
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 @@ | ||
Checking harness check_limits... | ||
|
||
Status: SATISFIED\ | ||
Description: "Zero Duration" | ||
|
||
Status: SATISFIED\ | ||
Description: "MAX Duration" | ||
|
||
Status: SATISFIED\ | ||
Description: "Max Secs" | ||
|
||
Status: SATISFIED\ | ||
Description: "Max millis" | ||
|
||
Status: SATISFIED\ | ||
Description: "Max micros" | ||
|
||
Status: SATISFIED\ | ||
Description: "Max nanos" | ||
|
||
Status: SUCCESS\ | ||
Description: ""Is Zero"" | ||
|
||
6 of 6 cover properties satisfied | ||
1 successfully verified harnesses, 0 failures |
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,19 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
//! Ensure that kani::any can be used with Duration. | ||
use std::time::Duration; | ||
|
||
#[kani::proof] | ||
fn check_limits() { | ||
let any_duration: Duration = kani::any(); | ||
kani::cover!(any_duration == Duration::ZERO, "Zero Duration"); | ||
kani::cover!(any_duration == Duration::MAX, "MAX Duration"); | ||
kani::cover!(any_duration == Duration::from_secs(u64::MAX), "Max Secs"); | ||
kani::cover!(any_duration == Duration::from_millis(u64::MAX), "Max millis"); | ||
kani::cover!(any_duration == Duration::from_micros(u64::MAX), "Max micros"); | ||
kani::cover!(any_duration == Duration::from_nanos(u64::MAX), "Max nanos"); | ||
|
||
assert_eq!(any_duration.is_zero(), any_duration == Duration::ZERO, "Is Zero"); | ||
} |
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
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 @@ | ||
Complete - 0 successfully verified harnesses, 2 failures, 2 total. |
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,19 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
//! Ensure Kani override doesn't result in extra warnings which could block compilation when | ||
//! users have strict lints. | ||
#![deny(unused_variables)] | ||
|
||
#[kani::proof] | ||
pub fn check_panic_format() { | ||
let val: bool = kani::any(); | ||
panic!("Invalid value {val}"); | ||
} | ||
|
||
#[kani::proof] | ||
pub fn check_panic_format_expr() { | ||
let val: bool = kani::any(); | ||
panic!("Invalid value {}", !val); | ||
} |