Skip to content

Commit 62ac325

Browse files
fix fmod_generic_impl_test and bazel
1 parent 88d0b6b commit 62ac325

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

libc/test/src/math/exhaustive/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ add_fp_unittest(
273273
fmod_generic_impl_test.cpp
274274
DEPENDS
275275
libc.src.__support.FPUtil.fp_bits
276+
libc.src.__support.FPUtil.manipulation_functions
276277
libc.src.__support.FPUtil.generic.fmod
277278
)
278279

libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,55 @@
66
//
77
//===----------------------------------------------------------------------===//
88
#include "src/__support/CPP/type_traits.h"
9+
#include "src/__support/FPUtil/FPBits.h"
10+
#include "src/__support/FPUtil/ManipulationFunctions.h" // ldexp
911
#include "src/__support/FPUtil/generic/FMod.h"
1012
#include "test/UnitTest/FPMatcher.h"
1113
#include "test/UnitTest/Test.h"
1214
#include "utils/MPFRWrapper/MPFRUtils.h"
1315

1416
#include <array>
15-
#include <cmath>
16-
#include <limits>
1717

1818
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
1919

2020
template <typename T, bool InverseMultiplication>
2121
class LlvmLibcFModTest : public LIBC_NAMESPACE::testing::Test {
2222

23-
using U = typename LIBC_NAMESPACE::fputil::FPBits<T>::StorageType;
23+
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
24+
using U = typename FPBits::StorageType;
2425
using DivisionHelper = LIBC_NAMESPACE::cpp::conditional_t<
2526
InverseMultiplication,
2627
LIBC_NAMESPACE::fputil::generic::FModDivisionInvMultHelper<U>,
2728
LIBC_NAMESPACE::fputil::generic::FModDivisionSimpleHelper<U>>;
2829

29-
static constexpr std::array<T, 11> test_bases = {
30+
static constexpr std::array<T, 11> TEST_BASES = {
3031
T(0.0),
3132
T(1.0),
3233
T(3.0),
3334
T(27.0),
3435
T(11.0 / 8.0),
3536
T(2.764443),
36-
T(1.0) - std::numeric_limits<T>::epsilon(),
37-
T(1.0) + std::numeric_limits<T>::epsilon(),
38-
T(M_PI),
39-
T(M_SQRT2),
40-
T(M_E),
41-
};
37+
T(1.0) - T(0x1.0p-23) - T(0x1.0p-52) - T(0x1.0p-112),
38+
T(1.0) + T(0x1.0p-23) + T(0x1.0p-52) + T(0x1.0p-112),
39+
T(3.14159265),
40+
T(1.41421356),
41+
T(2.71828183)};
4242

4343
public:
4444
void testExtensive() {
4545
using FMod = LIBC_NAMESPACE::fputil::generic::FMod<T, U, DivisionHelper>;
46-
using nl = std::numeric_limits<T>;
47-
int min2 = nl::min_exponent - nl::digits - 5;
48-
int max2 = nl::max_exponent + 3;
49-
for (T by : test_bases) {
46+
int min2 = -(FPBits::MAX_BIASED_EXPONENT + FPBits::SIG_LEN) / 2;
47+
int max2 = 3 + FPBits::MAX_BIASED_EXPONENT / 2;
48+
for (T by : TEST_BASES) {
5049
for (int iy = min2; iy < max2; iy++) {
51-
T y = by * std::ldexp(2, iy);
52-
if (y == 0 || !std::isfinite(y))
50+
T y = by * LIBC_NAMESPACE::fputil::ldexp(2.0, iy);
51+
FPBits y_bits(y);
52+
if (y_bits.is_zero() || !y_bits.is_finite())
5353
continue;
54-
for (T bx : test_bases) {
54+
for (T bx : TEST_BASES) {
5555
for (int ix = min2; ix < max2; ix++) {
56-
T x = bx * std::ldexp(2, ix);
57-
if (!std::isfinite(x))
56+
T x = bx * LIBC_NAMESPACE::fputil::ldexp(2.0, ix);
57+
if (!FPBits(x).is_finite())
5858
continue;
5959
T result = FMod::eval(x, y);
6060
mpfr::BinaryInput<T> input{x, y};

utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ libc_test(
6666
deps = [
6767
"//libc:__support_cpp_limits",
6868
"//libc:__support_cpp_span",
69-
"//libc:__support_cpp_limits",
7069
"//libc:__support_cpp_string_view",
7170
"//libc:__support_integer_literals",
7271
"//libc:__support_integer_to_string",
@@ -90,6 +89,7 @@ libc_test(
9089
"//libc:__support_cpp_optional",
9190
"//libc:__support_macros_properties_types",
9291
"//libc:__support_uint",
92+
"//libc:internal_includes",
9393
],
9494
)
9595

utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def math_test(name, hdrs = [], deps = [], **kwargs):
3434
"//libc:__support_math_extras",
3535
"//libc:__support_uint128",
3636
"//libc/test/UnitTest:fp_test_helpers",
37+
"//libc:internal_includes",
3738
] + deps,
3839
**kwargs
3940
)

0 commit comments

Comments
 (0)