Skip to content

Commit 71973fc

Browse files
committed
Consolidate is_sign_negative tests
1 parent 951ef57 commit 71973fc

File tree

5 files changed

+21
-52
lines changed

5 files changed

+21
-52
lines changed

library/coretests/tests/floats/f128.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ const NAN_MASK2: u128 = 0x00005555555555555555555555555555;
3939
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
4040
// the intrinsics.
4141

42-
#[test]
43-
fn test_is_sign_negative() {
44-
assert!(!f128::INFINITY.is_sign_negative());
45-
assert!(!1f128.is_sign_negative());
46-
assert!(!0f128.is_sign_negative());
47-
assert!((-0f128).is_sign_negative());
48-
assert!((-1f128).is_sign_negative());
49-
assert!(f128::NEG_INFINITY.is_sign_negative());
50-
assert!((1f128 / f128::NEG_INFINITY).is_sign_negative());
51-
assert!(!f128::NAN.is_sign_negative());
52-
assert!((-f128::NAN).is_sign_negative());
53-
}
54-
5542
#[test]
5643
fn test_next_up() {
5744
let tiny = f128::from_bits(TINY_BITS);

library/coretests/tests/floats/f16.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,6 @@ const NAN_MASK2: u16 = 0x0155;
4545
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
4646
// the intrinsics.
4747

48-
#[test]
49-
fn test_is_sign_negative() {
50-
assert!(!f16::INFINITY.is_sign_negative());
51-
assert!(!1f16.is_sign_negative());
52-
assert!(!0f16.is_sign_negative());
53-
assert!((-0f16).is_sign_negative());
54-
assert!((-1f16).is_sign_negative());
55-
assert!(f16::NEG_INFINITY.is_sign_negative());
56-
assert!((1f16 / f16::NEG_INFINITY).is_sign_negative());
57-
assert!(!f16::NAN.is_sign_negative());
58-
assert!((-f16::NAN).is_sign_negative());
59-
}
60-
6148
#[test]
6249
fn test_next_up() {
6350
let tiny = f16::from_bits(TINY_BITS);

library/coretests/tests/floats/f32.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,6 @@ const NAN_MASK2: u32 = 0x0055_5555;
2929
/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
3030
const APPROX_DELTA: f32 = if cfg!(miri) { 1e-4 } else { 1e-6 };
3131

32-
#[test]
33-
fn test_is_sign_negative() {
34-
assert!(!f32::INFINITY.is_sign_negative());
35-
assert!(!1f32.is_sign_negative());
36-
assert!(!0f32.is_sign_negative());
37-
assert!((-0f32).is_sign_negative());
38-
assert!((-1f32).is_sign_negative());
39-
assert!(f32::NEG_INFINITY.is_sign_negative());
40-
assert!((1f32 / f32::NEG_INFINITY).is_sign_negative());
41-
assert!(!f32::NAN.is_sign_negative());
42-
assert!((-f32::NAN).is_sign_negative());
43-
}
44-
4532
#[test]
4633
fn test_next_up() {
4734
let tiny = f32::from_bits(TINY_BITS);

library/coretests/tests/floats/f64.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@ const NAN_MASK1: u64 = 0x000a_aaaa_aaaa_aaaa;
2424
/// Second pattern over the mantissa
2525
const NAN_MASK2: u64 = 0x0005_5555_5555_5555;
2626

27-
#[test]
28-
fn test_is_sign_negative() {
29-
assert!(!f64::INFINITY.is_sign_negative());
30-
assert!(!1f64.is_sign_negative());
31-
assert!(!0f64.is_sign_negative());
32-
assert!((-0f64).is_sign_negative());
33-
assert!((-1f64).is_sign_negative());
34-
assert!(f64::NEG_INFINITY.is_sign_negative());
35-
assert!((1f64 / f64::NEG_INFINITY).is_sign_negative());
36-
assert!(!f64::NAN.is_sign_negative());
37-
assert!((-f64::NAN).is_sign_negative());
38-
}
39-
4027
#[test]
4128
fn test_next_up() {
4229
let tiny = f64::from_bits(TINY_BITS);

library/coretests/tests/floats/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,3 +998,24 @@ float_test! {
998998
assert!(!(-Float::NAN).is_sign_positive());
999999
}
10001000
}
1001+
1002+
float_test! {
1003+
name: is_sign_negative,
1004+
attrs: {
1005+
f16: #[cfg(any(miri, target_has_reliable_f16))],
1006+
f128: #[cfg(any(miri, target_has_reliable_f128))],
1007+
},
1008+
test<Float> {
1009+
let one: Float = 1.0;
1010+
let zero: Float = 0.0;
1011+
assert!(!Float::INFINITY.is_sign_negative());
1012+
assert!(!one.is_sign_negative());
1013+
assert!(!zero.is_sign_negative());
1014+
assert!((-zero).is_sign_negative());
1015+
assert!((-one).is_sign_negative());
1016+
assert!(Float::NEG_INFINITY.is_sign_negative());
1017+
assert!((one / Float::NEG_INFINITY).is_sign_negative());
1018+
assert!(!Float::NAN.is_sign_negative());
1019+
assert!((-Float::NAN).is_sign_negative());
1020+
}
1021+
}

0 commit comments

Comments
 (0)