-
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
61c9fbe
commit 087b22b
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
tests/expected/attr-invariant/check_arbitrary/check_arbitrary.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,23 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! Check that the `kani::invariant` attribute automatically generates the | ||
//! `Arbitrary` implementation, and also that the values it generates respect | ||
//! the type invariant. | ||
|
||
extern crate kani; | ||
use kani::Invariant; | ||
|
||
#[kani::invariant(*x >= 0 && *y >= 0)] | ||
struct Point { | ||
x: i32, | ||
y: i32, | ||
} | ||
|
||
#[kani::proof] | ||
fn check_arbitrary() { | ||
let point: Point = kani::any(); | ||
assert!(point.x >= 0); | ||
assert!(point.y >= 0); | ||
assert!(point.is_safe()); | ||
} |
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 @@ | ||
Check 1: check_arbitrary.assertion.1\ | ||
- Status: SUCCESS\ | ||
- Description: "assertion failed: point.x >= 0" | ||
|
||
Check 2: check_arbitrary.assertion.2\ | ||
- Status: SUCCESS\ | ||
- Description: "assertion failed: point.y >= 0" | ||
|
||
Check 3: check_arbitrary.assertion.3\ | ||
- Status: SUCCESS\ | ||
- Description: "assertion failed: point.is_safe()" |