Skip to content

Commit 951ef57

Browse files
committed
Consolidate is_positive tests
1 parent 83878ea commit 951ef57

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_positive() {
44-
assert!(f128::INFINITY.is_sign_positive());
45-
assert!(1f128.is_sign_positive());
46-
assert!(0f128.is_sign_positive());
47-
assert!(!(-0f128).is_sign_positive());
48-
assert!(!(-1f128).is_sign_positive());
49-
assert!(!f128::NEG_INFINITY.is_sign_positive());
50-
assert!(!(1f128 / f128::NEG_INFINITY).is_sign_positive());
51-
assert!(f128::NAN.is_sign_positive());
52-
assert!(!(-f128::NAN).is_sign_positive());
53-
}
54-
5542
#[test]
5643
fn test_is_sign_negative() {
5744
assert!(!f128::INFINITY.is_sign_negative());

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_positive() {
50-
assert!(f16::INFINITY.is_sign_positive());
51-
assert!(1f16.is_sign_positive());
52-
assert!(0f16.is_sign_positive());
53-
assert!(!(-0f16).is_sign_positive());
54-
assert!(!(-1f16).is_sign_positive());
55-
assert!(!f16::NEG_INFINITY.is_sign_positive());
56-
assert!(!(1f16 / f16::NEG_INFINITY).is_sign_positive());
57-
assert!(f16::NAN.is_sign_positive());
58-
assert!(!(-f16::NAN).is_sign_positive());
59-
}
60-
6148
#[test]
6249
fn test_is_sign_negative() {
6350
assert!(!f16::INFINITY.is_sign_negative());

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_positive() {
34-
assert!(f32::INFINITY.is_sign_positive());
35-
assert!(1f32.is_sign_positive());
36-
assert!(0f32.is_sign_positive());
37-
assert!(!(-0f32).is_sign_positive());
38-
assert!(!(-1f32).is_sign_positive());
39-
assert!(!f32::NEG_INFINITY.is_sign_positive());
40-
assert!(!(1f32 / f32::NEG_INFINITY).is_sign_positive());
41-
assert!(f32::NAN.is_sign_positive());
42-
assert!(!(-f32::NAN).is_sign_positive());
43-
}
44-
4532
#[test]
4633
fn test_is_sign_negative() {
4734
assert!(!f32::INFINITY.is_sign_negative());

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_positive() {
29-
assert!(f64::INFINITY.is_sign_positive());
30-
assert!(1f64.is_sign_positive());
31-
assert!(0f64.is_sign_positive());
32-
assert!(!(-0f64).is_sign_positive());
33-
assert!(!(-1f64).is_sign_positive());
34-
assert!(!f64::NEG_INFINITY.is_sign_positive());
35-
assert!(!(1f64 / f64::NEG_INFINITY).is_sign_positive());
36-
assert!(f64::NAN.is_sign_positive());
37-
assert!(!(-f64::NAN).is_sign_positive());
38-
}
39-
4027
#[test]
4128
fn test_is_sign_negative() {
4229
assert!(!f64::INFINITY.is_sign_negative());

library/coretests/tests/floats/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,3 +977,24 @@ float_test! {
977977
assert!(Float::NAN.signum().is_nan());
978978
}
979979
}
980+
981+
float_test! {
982+
name: is_sign_positive,
983+
attrs: {
984+
f16: #[cfg(any(miri, target_has_reliable_f16))],
985+
f128: #[cfg(any(miri, target_has_reliable_f128))],
986+
},
987+
test<Float> {
988+
let one: Float = 1.0;
989+
let zero: Float = 0.0;
990+
assert!(Float::INFINITY.is_sign_positive());
991+
assert!(one.is_sign_positive());
992+
assert!(zero.is_sign_positive());
993+
assert!(!(-zero).is_sign_positive());
994+
assert!(!(-one).is_sign_positive());
995+
assert!(!Float::NEG_INFINITY.is_sign_positive());
996+
assert!(!(one / Float::NEG_INFINITY).is_sign_positive());
997+
assert!(Float::NAN.is_sign_positive());
998+
assert!(!(-Float::NAN).is_sign_positive());
999+
}
1000+
}

0 commit comments

Comments
 (0)