Skip to content

Commit e7a8654

Browse files
committed
test_nan: ensure the NAN contant is quiet
1 parent fae7785 commit e7a8654

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

library/std/tests/floats/f128.rs

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ fn test_nan() {
112112
assert!(!nan.is_sign_negative());
113113
assert!(!nan.is_normal());
114114
assert_eq!(Fp::Nan, nan.classify());
115+
// Ensure the quiet bit is set.
116+
assert!(nan.to_bits() & (1 << (f128::MANTISSA_DIGITS - 2)) != 0);
115117
}
116118

117119
#[test]

library/std/tests/floats/f16.rs

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ fn test_nan() {
9595
assert!(!nan.is_sign_negative());
9696
assert!(!nan.is_normal());
9797
assert_eq!(Fp::Nan, nan.classify());
98+
// Ensure the quiet bit is set.
99+
assert!(nan.to_bits() & (1 << (f16::MANTISSA_DIGITS - 2)) != 0);
98100
}
99101

100102
#[test]

library/std/tests/floats/f32.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ fn test_nan() {
7272
assert!(nan.is_sign_positive());
7373
assert!(!nan.is_sign_negative());
7474
assert_eq!(Fp::Nan, nan.classify());
75+
// Ensure the quiet bit is set.
76+
assert!(nan.to_bits() & (1 << (f32::MANTISSA_DIGITS - 2)) != 0);
7577
}
7678

7779
#[test]

library/std/tests/floats/f64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ fn test_nan() {
6060
assert!(nan.is_sign_positive());
6161
assert!(!nan.is_sign_negative());
6262
assert_eq!(Fp::Nan, nan.classify());
63+
// Ensure the quiet bit is set.
64+
assert!(nan.to_bits() & (1 << (f64::MANTISSA_DIGITS - 2)) != 0);
6365
}
6466

6567
#[test]

0 commit comments

Comments
 (0)