forked from model-checking/kani
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requires fixes in CBMC's sqrt* implementations.
- Loading branch information
1 parent
a82bad4
commit cd236fa
Showing
3 changed files
with
32 additions
and
4 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,28 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#[kani::proof] | ||
fn verify_sqrt32() { | ||
let positive = 4.0_f32; | ||
let negative = -4.0_f32; | ||
let negative_zero = -0.0_f32; | ||
|
||
let abs_difference = (positive.sqrt() - 2.0).abs(); | ||
|
||
assert!(abs_difference <= f32::EPSILON); | ||
assert!(negative.sqrt().is_nan()); | ||
assert!(negative_zero.sqrt() == negative_zero); | ||
} | ||
|
||
#[kani::proof] | ||
fn verify_sqrt64() { | ||
let positive = 4.0_f64; | ||
let negative = -4.0_f64; | ||
let negative_zero = -0.0_f64; | ||
|
||
let abs_difference = (positive.sqrt() - 2.0).abs(); | ||
|
||
assert!(abs_difference <= 1e-10); | ||
assert!(negative.sqrt().is_nan()); | ||
assert!(negative_zero.sqrt() == negative_zero); | ||
} |