Skip to content

Commit c63c413

Browse files
committed
a few more inf/nan/negz tests
1 parent 910afef commit c63c413

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/run-pass/float.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,22 @@ fn main() {
1818
assert_eq(-{5.0_f64}, -5.0_f64);
1919
// infinities, NaN
2020
assert!((5.0_f32/0.0).is_infinite());
21+
assert_ne!({5.0_f32/0.0}, {-5.0_f32/0.0});
2122
assert!((5.0_f64/0.0).is_infinite());
23+
assert_ne!({5.0_f64/0.0}, {5.0_f64/-0.0});
2224
assert!((-5.0_f32).sqrt().is_nan());
2325
assert!((-5.0_f64).sqrt().is_nan());
26+
assert_ne!(f32::NAN, f32::NAN);
27+
assert_ne!(f64::NAN, f64::NAN);
28+
// negative zero
29+
let posz = 0.0f32;
30+
let negz = -0.0f32;
31+
assert_eq(posz, negz);
32+
assert_ne!(posz.to_bits(), negz.to_bits());
33+
let posz = 0.0f64;
34+
let negz = -0.0f64;
35+
assert_eq(posz, negz);
36+
assert_ne!(posz.to_bits(), negz.to_bits());
2437
// byte-level transmute
2538
let x: u64 = unsafe { std::mem::transmute(42.0_f64) };
2639
let y: f64 = unsafe { std::mem::transmute(x) };

0 commit comments

Comments
 (0)