File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
tests/kani/Intrinsics/Math Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3
+
4
+ // Check that `fabsf32` returns the expected results: absolute value if argument
5
+ // is not NaN, otherwise NaN
6
+ #![ feature( core_intrinsics) ]
7
+
8
+ #[ kani:: proof]
9
+ fn test_abs_finite ( ) {
10
+ let x: f32 = kani:: any ( ) ;
11
+ kani:: assume ( !x. is_nan ( ) ) ;
12
+ let abs_x = unsafe { std:: intrinsics:: fabsf32 ( x) } ;
13
+ if x < 0.0 {
14
+ assert ! ( -x == abs_x) ;
15
+ } else {
16
+ assert ! ( x == abs_x) ;
17
+ }
18
+ }
19
+
20
+ #[ kani:: proof]
21
+ fn test_abs_nan ( ) {
22
+ let x: f32 = kani:: any ( ) ;
23
+ kani:: assume ( x. is_nan ( ) ) ;
24
+ let abs_x = unsafe { std:: intrinsics:: fabsf32 ( x) } ;
25
+ assert ! ( abs_x. is_nan( ) ) ;
26
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3
+
4
+ // Check that `fabsf64` returns the expected results: absolute value if argument
5
+ // is not NaN, otherwise NaN
6
+ #![ feature( core_intrinsics) ]
7
+
8
+ #[ kani:: proof]
9
+ fn test_abs_finite ( ) {
10
+ let x: f64 = kani:: any ( ) ;
11
+ kani:: assume ( !x. is_nan ( ) ) ;
12
+ let abs_x = unsafe { std:: intrinsics:: fabsf64 ( x) } ;
13
+ if x < 0.0 {
14
+ assert ! ( -x == abs_x) ;
15
+ } else {
16
+ assert ! ( x == abs_x) ;
17
+ }
18
+ }
19
+
20
+ #[ kani:: proof]
21
+ fn test_abs_nan ( ) {
22
+ let x: f64 = kani:: any ( ) ;
23
+ kani:: assume ( x. is_nan ( ) ) ;
24
+ let abs_x = unsafe { std:: intrinsics:: fabsf64 ( x) } ;
25
+ assert ! ( abs_x. is_nan( ) ) ;
26
+ }
You can’t perform that action at this time.
0 commit comments