Skip to content

Commit 83164fc

Browse files
committed
coretests: also test f16 and f128 in const (but only there for now)
1 parent 46264e6 commit 83164fc

File tree

1 file changed

+29
-4
lines changed
  • library/coretests/tests/num

1 file changed

+29
-4
lines changed

library/coretests/tests/num/mod.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,11 @@ macro_rules! test_float {
891891
// be safely doubled, while j is significantly smaller.
892892
for i in $max_exp.saturating_sub(64)..$max_exp {
893893
for j in 0..64u8 {
894-
let large = <$fty>::from(2.0f32).powi(i);
894+
let large = (2.0 as $fty).powi(i);
895895
// a much smaller number, such that there is no chance of overflow to test
896896
// potential double rounding in midpoint's implementation.
897-
let small = <$fty>::from(2.0f32).powi($max_exp - 1)
898-
* <$fty>::EPSILON
899-
* <$fty>::from(j);
897+
let small =
898+
(2.0 as $fty).powi($max_exp - 1) * <$fty>::EPSILON * <$fty>::from(j);
900899

901900
let naive = (large + small) / 2.0;
902901
let midpoint = large.midpoint(small);
@@ -948,6 +947,19 @@ macro_rules! float_const_assert {
948947
};
949948
}
950949

950+
// FIXME(f16_f128): `f16` is only tested in consts for now.
951+
test_float!(
952+
f16_const,
953+
float_const_assert,
954+
f16,
955+
f16::INFINITY,
956+
f16::NEG_INFINITY,
957+
f16::NAN,
958+
f16::MIN,
959+
f16::MAX,
960+
f16::MIN_POSITIVE,
961+
f16::MAX_EXP
962+
);
951963
test_float!(
952964
f32,
953965
float_assert,
@@ -996,3 +1008,16 @@ test_float!(
9961008
f64::MIN_POSITIVE,
9971009
f64::MAX_EXP
9981010
);
1011+
// FIXME(f16_f128): `f128` is only tested in consts for now.
1012+
test_float!(
1013+
f128_const,
1014+
float_const_assert,
1015+
f128,
1016+
f128::INFINITY,
1017+
f128::NEG_INFINITY,
1018+
f128::NAN,
1019+
f128::MIN,
1020+
f128::MAX,
1021+
f128::MIN_POSITIVE,
1022+
f128::MAX_EXP
1023+
);

0 commit comments

Comments
 (0)