diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt index 302af3044ca3d6..bc7fb88c8ff36e 100644 --- a/libc/test/UnitTest/CMakeLists.txt +++ b/libc/test/UnitTest/CMakeLists.txt @@ -108,6 +108,40 @@ add_header_library( libc.src.__support.CPP.type_traits ) +add_unittest_framework_library( + LibcFPExceptionHelpers + SRCS + FPExceptMatcher.cpp + HDRS + FPExceptMatcher.h + DEPENDS + LibcTest + libc.src.__support.FPUtil.fp_bits + libc.src.__support.FPUtil.fenv_impl + libc.hdr.types.fenv_t + libc.hdr.fenv_macros +) + +add_header_library( + ErrnoSetterMatcher + HDRS + ErrnoSetterMatcher.h + DEPENDS + libc.src.__support.common + libc.src.__support.FPUtil.fp_bits + libc.src.__support.StringUtil.error_to_string + libc.src.errno.errno +) + +add_header_library( + ErrnoSafeTest + HDRS + ErrnoSafeTest.h + DEPENDS + libc.src.__support.CPP.utility + libc.src.errno.errno +) + add_unittest_framework_library( LibcFPTestHelpers SRCS @@ -116,30 +150,22 @@ add_unittest_framework_library( HDRS FEnvSafeTest.h FPMatcher.h + FPTest.h RoundingModeUtils.h DEPENDS LibcTest + ErrnoSafeTest + ErrnoSetterMatcher + LibcFPExceptionHelpers libc.test.UnitTest.string_utils libc.src.__support.CPP.array + libc.src.__support.CPP.utility libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.fpbits_str libc.src.__support.FPUtil.fenv_impl libc.src.__support.FPUtil.rounding_mode ) -add_unittest_framework_library( - LibcFPExceptionHelpers - SRCS - FPExceptMatcher.cpp - HDRS - FPExceptMatcher.h - DEPENDS - LibcTest - libc.src.__support.FPUtil.fp_bits - libc.src.__support.FPUtil.fenv_impl - libc.hdr.types.fenv_t -) - add_unittest_framework_library( LibcMemoryHelpers SRCS @@ -176,14 +202,3 @@ add_unittest_framework_library( libc.src.stdio.scanf_core.core_structs libc.test.UnitTest.string_utils ) - -add_header_library( - ErrnoSetterMatcher - HDRS - ErrnoSetterMatcher.h - DEPENDS - libc.src.__support.common - libc.src.__support.FPUtil.fp_bits - libc.src.__support.StringUtil.error_to_string - libc.src.errno.errno -) diff --git a/libc/test/UnitTest/ErrnoSafeTest.h b/libc/test/UnitTest/ErrnoSafeTest.h new file mode 100644 index 00000000000000..bad4ab764ac0bf --- /dev/null +++ b/libc/test/UnitTest/ErrnoSafeTest.h @@ -0,0 +1,26 @@ +//===-- ErrnoSafeTestFixture.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_TEST_UNITTEST_ERRNOSAFETEST_H +#define LLVM_LIBC_TEST_UNITTEST_ERRNOSAFETEST_H + +#include "src/__support/CPP/utility.h" +#include "src/errno/libc_errno.h" +#include "test/UnitTest/Test.h" + +namespace LIBC_NAMESPACE::testing { + +// This is a test fixture for clearing errno before the start of a test case. +class ErrnoSafeTest : virtual public Test { +public: + void SetUp() override { LIBC_NAMESPACE::libc_errno = 0; } +}; + +} // namespace LIBC_NAMESPACE::testing + +#endif // LLVM_LIBC_TEST_UNITTEST_ERRNOSAFETEST_H diff --git a/libc/test/UnitTest/ErrnoSetterMatcher.h b/libc/test/UnitTest/ErrnoSetterMatcher.h index 745ba4182023e2..d0f284b733309b 100644 --- a/libc/test/UnitTest/ErrnoSetterMatcher.h +++ b/libc/test/UnitTest/ErrnoSetterMatcher.h @@ -58,6 +58,9 @@ template struct Comparator { #endif }; +// TODO: this should check errno and not always need a return value to +// also compare against. The FP and non-FP matching is redundant with +// the other matchers pulled in through Test.h and FPMatcher.h. template class ErrnoSetterMatcher : public Matcher { Comparator return_cmp; Comparator errno_cmp; @@ -184,4 +187,37 @@ static ErrnoSetterMatcherBuilder returns(internal::Comparator cmp) { } // namespace testing } // namespace LIBC_NAMESPACE +// Used to check that `LIBC_NAMESPACE::libc_errno` was 0 or a specific +// errno after executing `expr_or_statement` from a state where +// `LIBC_NAMESPACE::libc_errno` was 0. This is generic, so does not check +// `math_errhandling & MATH_ERRNO` before errno matching, see FPTest.h for +// assertions that check this. +// +// Expects `expected` to be convertible to int type. +// +// Does not return the value of expr_or_statement, i.e., intended usage +// is: `EXPECT_ERRNO(EDOM, EXPECT_EQ(..., ...));` or +// ``` +// EXPECT_ERRNO(EDOM, { +// stmt; +// ... +// }); +// ``` +// +// TODO: this currently uses `ErrnoSetterMatcher` for the nice explanation on +// failed errno matching. `ErrnoSetterMatcher` requires a return value to also +// always check, so this code always checks 0 against 0 for the return value-- +// it is not actually checking the value of `expr_or_statement` per above doc +// comments. When `ErrnoSetterMatcher` is changed to not always check return +// values, change this also. +#define EXPECT_ERRNO(expected, expr_or_statement) \ + do { \ + LIBC_NAMESPACE::libc_errno = 0; \ + expr_or_statement; \ + EXPECT_THAT( \ + 0, LIBC_NAMESPACE::testing::internal::ErrnoSetterMatcher( \ + LIBC_NAMESPACE::testing::ErrnoSetterMatcher::EQ(0), \ + LIBC_NAMESPACE::testing::ErrnoSetterMatcher::EQ((expected)))); \ + } while (0) + #endif // LLVM_LIBC_TEST_ERRNOSETTERMATCHER_H diff --git a/libc/test/UnitTest/FEnvSafeTest.h b/libc/test/UnitTest/FEnvSafeTest.h index d5a8bb7ee667ce..6ac9fcf89ffd21 100644 --- a/libc/test/UnitTest/FEnvSafeTest.h +++ b/libc/test/UnitTest/FEnvSafeTest.h @@ -18,7 +18,7 @@ namespace LIBC_NAMESPACE::testing { // This provides a test fixture (or base class for other test fixtures) that // asserts that each test does not leave the FPU state represented by `fenv_t` // (aka `FPState`) perturbed from its initial state. -class FEnvSafeTest : public Test { +class FEnvSafeTest : virtual public Test { public: void TearDown() override; diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp index c1dfc539246623..c10da56e07d92f 100644 --- a/libc/test/UnitTest/FPExceptMatcher.cpp +++ b/libc/test/UnitTest/FPExceptMatcher.cpp @@ -10,6 +10,7 @@ #include "test/UnitTest/Test.h" +#include "hdr/fenv_macros.h" #include "hdr/types/fenv_t.h" #include "src/__support/FPUtil/FEnvImpl.h" #include @@ -35,7 +36,7 @@ static void sigfpeHandler(int sig) { siglongjmp(jumpBuffer, -1); } -FPExceptMatcher::FPExceptMatcher(FunctionCaller *func) { +FPExceptCallableMatcher::FPExceptCallableMatcher(FunctionCaller *func) { auto oldSIGFPEHandler = signal(SIGFPE, &sigfpeHandler); std::unique_ptr funcUP(func); diff --git a/libc/test/UnitTest/FPExceptMatcher.h b/libc/test/UnitTest/FPExceptMatcher.h index 5136e381081ee4..2375dd0b951815 100644 --- a/libc/test/UnitTest/FPExceptMatcher.h +++ b/libc/test/UnitTest/FPExceptMatcher.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_UNITTEST_FPEXCEPTMATCHER_H #define LLVM_LIBC_TEST_UNITTEST_FPEXCEPTMATCHER_H +#include "hdr/fenv_macros.h" #include "test/UnitTest/Test.h" #include "test/UnitTest/TestLogger.h" @@ -17,9 +18,71 @@ namespace LIBC_NAMESPACE { namespace testing { +// Used to compare FP exception flag states with nice error printing +class FPExceptMatcher : public Matcher { + const int expected; + int actual; + +public: + explicit FPExceptMatcher(int expected) : expected(expected) {} + + void explainError() override { + tlog << "Expected floating point exceptions: " << expected << ' '; + printExcepts(expected); + tlog << '\n'; + + tlog << "Actual floating point exceptions: " << actual << ' '; + printExcepts(actual); + tlog << '\n'; + } + + bool match(int got) { + actual = got; + return got == expected; + } + +private: + void printExcepts(int excepts) { + if (!excepts) { + tlog << "(no exceptions)"; + return; + } + + bool firstPrinted = false; + auto printWithPipe = [&](const char *name) { + if (firstPrinted) + tlog << " | "; + + tlog << name; + + firstPrinted = true; + }; + + tlog << '('; + + if (FE_DIVBYZERO & excepts) + printWithPipe("FE_DIVBYZERO"); + + if (FE_INEXACT & excepts) + printWithPipe("FE_INEXACT"); + + if (FE_INVALID & excepts) + printWithPipe("FE_INVALID"); + + if (FE_OVERFLOW & excepts) + printWithPipe("FE_OVERFLOW"); + + if (FE_UNDERFLOW & excepts) + printWithPipe("FE_UNDERFLOW"); + + tlog << ')'; + } +}; + // TODO: Make the matcher match specific exceptions instead of just identifying // that an exception was raised. -class FPExceptMatcher : public Matcher { +// Used in death tests for fenv +class FPExceptCallableMatcher : public Matcher { bool exceptionRaised; public: @@ -40,7 +103,7 @@ class FPExceptMatcher : public Matcher { } // Takes ownership of func. - explicit FPExceptMatcher(FunctionCaller *func); + explicit FPExceptCallableMatcher(FunctionCaller *func); bool match(bool unused) { return exceptionRaised; } @@ -53,11 +116,42 @@ class FPExceptMatcher : public Matcher { } // namespace testing } // namespace LIBC_NAMESPACE +// Matches on the FP exception flag `expected` being *equal* to FP exception +// flag `actual` +#define EXPECT_FP_EXCEPTION_EQ(expected, actual) \ + EXPECT_THAT((actual), LIBC_NAMESPACE::testing::FPExceptMatcher((expected))) + +#define ASSERT_FP_EXCEPT_EQ(expected, actual) \ + ASSERT_THAT((actual), LIBC_NAMESPACE::testing::FPExceptMatcher((expected))) + #define ASSERT_RAISES_FP_EXCEPT(func) \ ASSERT_THAT( \ true, \ - LIBC_NAMESPACE::testing::FPExceptMatcher( \ - LIBC_NAMESPACE::testing::FPExceptMatcher::getFunctionCaller(func))) + LIBC_NAMESPACE::testing::FPExceptCallableMatcher( \ + LIBC_NAMESPACE::testing::FPExceptCallableMatcher::getFunctionCaller( \ + func))) + +// Does not return the value of `expr_or_statement`, i.e., intended usage +// is: `EXPECT_FP_EXCEPT(FE_INVALID, EXPECT_FP_EQ(..., ...));` or +// ``` +// EXPECT_FP_EXCEPT(FE_ALL_EXCEPT, { +// stmt; +// ... +// }); +// ``` +// Ensures that fp excepts are cleared before executing `expr_or_statement` +// Checking (expected = 0) should ensure that no exceptions were set +#define EXPECT_FP_EXCEPTION(expected, expr_or_statement) \ + do { \ + LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \ + expr_or_statement; \ + int expected_ = (expected); \ + int mask_ = expected_ ? expected_ : FE_ALL_EXCEPT; \ + if (math_errhandling & MATH_ERREXCEPT) { \ + EXPECT_FP_EXCEPTION_EQ(expected_, \ + LIBC_NAMESPACE::fputil::test_except(mask_)); \ + } \ + } while (0) #else // !LIBC_TEST_HAS_MATCHERS() diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index 26af5cec02b587..98682e81806d44 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -61,60 +61,9 @@ template FPMatcher getMatcher(T expectedValue) { return FPMatcher(expectedValue); } -template struct FPTest : public Test { - using FPBits = LIBC_NAMESPACE::fputil::FPBits; - using StorageType = typename FPBits::StorageType; - static constexpr StorageType STORAGE_MAX = - LIBC_NAMESPACE::cpp::numeric_limits::max(); - static constexpr T zero = FPBits::zero(Sign::POS).get_val(); - static constexpr T neg_zero = FPBits::zero(Sign::NEG).get_val(); - static constexpr T aNaN = FPBits::quiet_nan().get_val(); - static constexpr T sNaN = FPBits::signaling_nan().get_val(); - static constexpr T inf = FPBits::inf(Sign::POS).get_val(); - static constexpr T neg_inf = FPBits::inf(Sign::NEG).get_val(); - static constexpr T min_normal = FPBits::min_normal().get_val(); - static constexpr T max_normal = FPBits::max_normal().get_val(); - static constexpr T min_denormal = FPBits::min_subnormal().get_val(); - static constexpr T max_denormal = FPBits::max_subnormal().get_val(); - - static constexpr int N_ROUNDING_MODES = 4; - static constexpr fputil::testing::RoundingMode ROUNDING_MODES[4] = { - fputil::testing::RoundingMode::Nearest, - fputil::testing::RoundingMode::Upward, - fputil::testing::RoundingMode::Downward, - fputil::testing::RoundingMode::TowardZero, - }; -}; - } // namespace testing } // namespace LIBC_NAMESPACE -#define DECLARE_SPECIAL_CONSTANTS(T) \ - using FPBits = LIBC_NAMESPACE::fputil::FPBits; \ - using StorageType = typename FPBits::StorageType; \ - \ - static constexpr StorageType STORAGE_MAX = \ - LIBC_NAMESPACE::cpp::numeric_limits::max(); \ - const T zero = FPBits::zero(Sign::POS).get_val(); \ - const T neg_zero = FPBits::zero(Sign::NEG).get_val(); \ - const T aNaN = FPBits::quiet_nan().get_val(); \ - const T sNaN = FPBits::signaling_nan().get_val(); \ - const T inf = FPBits::inf(Sign::POS).get_val(); \ - const T neg_inf = FPBits::inf(Sign::NEG).get_val(); \ - const T min_normal = FPBits::min_normal().get_val(); \ - const T max_normal = FPBits::max_normal(Sign::POS).get_val(); \ - const T neg_max_normal = FPBits::max_normal(Sign::NEG).get_val(); \ - const T min_denormal = FPBits::min_subnormal(Sign::POS).get_val(); \ - const T neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val(); \ - const T max_denormal = FPBits::max_subnormal().get_val(); \ - static constexpr int UNKNOWN_MATH_ROUNDING_DIRECTION = 99; \ - static constexpr LIBC_NAMESPACE::cpp::array \ - MATH_ROUNDING_DIRECTIONS_INCLUDING_UNKNOWN = { \ - FP_INT_UPWARD, FP_INT_DOWNWARD, \ - FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO, \ - FP_INT_TONEAREST, UNKNOWN_MATH_ROUNDING_DIRECTION, \ - }; - #define EXPECT_FP_EQ(expected, actual) \ EXPECT_THAT(actual, LIBC_NAMESPACE::testing::getMatcher< \ LIBC_NAMESPACE::testing::TestCond::EQ>(expected)) @@ -156,7 +105,7 @@ template struct FPTest : public Test { } \ } while (0) -#define EXPECT_FP_EXCEPTION(expected) \ +#define EXPECT_FP_EXCEPTION_HAPPENED(expected) \ do { \ if (math_errhandling & MATH_ERREXCEPT) { \ EXPECT_EQ(LIBC_NAMESPACE::fputil::test_except(FE_ALL_EXCEPT) & \ @@ -165,7 +114,7 @@ template struct FPTest : public Test { } \ } while (0) -#define ASSERT_FP_EXCEPTION(expected) \ +#define ASSERT_FP_EXCEPTION_HAPPENED(expected) \ do { \ if (math_errhandling & MATH_ERREXCEPT) { \ ASSERT_EQ(LIBC_NAMESPACE::fputil::test_except(FE_ALL_EXCEPT) & \ @@ -178,46 +127,40 @@ template struct FPTest : public Test { do { \ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \ EXPECT_FP_EQ(expected_val, actual_val); \ - EXPECT_FP_EXCEPTION(expected_except); \ + EXPECT_FP_EXCEPTION_HAPPENED(expected_except); \ } while (0) #define EXPECT_FP_IS_NAN_WITH_EXCEPTION(actual_val, expected_except) \ do { \ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \ EXPECT_FP_IS_NAN(actual_val); \ - EXPECT_FP_EXCEPTION(expected_except); \ + EXPECT_FP_EXCEPTION_HAPPENED(expected_except); \ } while (0) -#define EXPECT_FP_EQ_ALL_ROUNDING(expected, actual) \ +#define FOR_ROUNDING_(rounding_mode, expr_or_statement) \ do { \ using namespace LIBC_NAMESPACE::fputil::testing; \ - ForceRoundingMode __r1(RoundingMode::Nearest); \ - if (__r1.success) { \ - EXPECT_FP_EQ((expected), (actual)); \ - } \ - ForceRoundingMode __r2(RoundingMode::Upward); \ - if (__r2.success) { \ - EXPECT_FP_EQ((expected), (actual)); \ - } \ - ForceRoundingMode __r3(RoundingMode::Downward); \ - if (__r3.success) { \ - EXPECT_FP_EQ((expected), (actual)); \ - } \ - ForceRoundingMode __r4(RoundingMode::TowardZero); \ - if (__r4.success) { \ - EXPECT_FP_EQ((expected), (actual)); \ + ForceRoundingMode __r((rounding_mode)); \ + if (__r.success) { \ + expr_or_statement; \ } \ } while (0) -#define EXPECT_FP_EQ_ROUNDING_MODE(expected, actual, rounding_mode) \ +#define FOR_ALL_ROUNDING_(expr_or_statement) \ do { \ using namespace LIBC_NAMESPACE::fputil::testing; \ - ForceRoundingMode __r((rounding_mode)); \ - if (__r.success) { \ - EXPECT_FP_EQ((expected), (actual)); \ - } \ + FOR_ROUNDING_(RoundingMode::Nearest, expr_or_statement); \ + FOR_ROUNDING_(RoundingMode::Upward, expr_or_statement); \ + FOR_ROUNDING_(RoundingMode::Downward, expr_or_statement); \ + FOR_ROUNDING_(RoundingMode::TowardZero, expr_or_statement); \ } while (0) +#define EXPECT_FP_EQ_ALL_ROUNDING(expected, actual) \ + FOR_ALL_ROUNDING_(EXPECT_FP_EQ((expected), (actual))) + +#define EXPECT_FP_EQ_ROUNDING_MODE(expected, actual, rounding_mode) \ + FOR_ROUNDING_(rounding_mode, EXPECT_FP_EQ((expected), (actual))) + #define EXPECT_FP_EQ_ROUNDING_NEAREST(expected, actual) \ EXPECT_FP_EQ_ROUNDING_MODE((expected), (actual), RoundingMode::Nearest) diff --git a/libc/test/UnitTest/FPTest.h b/libc/test/UnitTest/FPTest.h new file mode 100644 index 00000000000000..08c26aab19b5b1 --- /dev/null +++ b/libc/test/UnitTest/FPTest.h @@ -0,0 +1,112 @@ +//===-- FPTest.h -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_TEST_UNITTEST_FPTEST_H +#define LLVM_LIBC_TEST_UNITTEST_FPTEST_H + +#include "src/__support/CPP/utility.h" +#include "src/__support/FPUtil/FEnvImpl.h" +#include "src/__support/FPUtil/FPBits.h" +#include "test/UnitTest/ErrnoSafeTest.h" // Test fixture for clearing errno +#include "test/UnitTest/ErrnoSetterMatcher.h" // Per-assertion clear/check errno +#include "test/UnitTest/FEnvSafeTest.h" // Test fixture for resetting fenv +#include "test/UnitTest/FPExceptMatcher.h" // Per-assertion clear/check fp exns +#include "test/UnitTest/FPMatcher.h" // Matchers/assertions for fp values +#include "test/UnitTest/Test.h" + +#define DECLARE_SPECIAL_CONSTANTS(T) \ + using FPBits = LIBC_NAMESPACE::fputil::FPBits; \ + using StorageType = typename FPBits::StorageType; \ + \ + static constexpr StorageType STORAGE_MAX = \ + LIBC_NAMESPACE::cpp::numeric_limits::max(); \ + const T zero = FPBits::zero(Sign::POS).get_val(); \ + const T neg_zero = FPBits::zero(Sign::NEG).get_val(); \ + const T aNaN = FPBits::quiet_nan().get_val(); \ + const T sNaN = FPBits::signaling_nan().get_val(); \ + const T inf = FPBits::inf(Sign::POS).get_val(); \ + const T neg_inf = FPBits::inf(Sign::NEG).get_val(); \ + const T min_normal = FPBits::min_normal().get_val(); \ + const T max_normal = FPBits::max_normal(Sign::POS).get_val(); \ + const T neg_max_normal = FPBits::max_normal(Sign::NEG).get_val(); \ + const T min_denormal = FPBits::min_subnormal(Sign::POS).get_val(); \ + const T neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val(); \ + const T max_denormal = FPBits::max_subnormal().get_val(); \ + static constexpr int UNKNOWN_MATH_ROUNDING_DIRECTION = 99; \ + static constexpr LIBC_NAMESPACE::cpp::array \ + MATH_ROUNDING_DIRECTIONS_INCLUDING_UNKNOWN = { \ + FP_INT_UPWARD, FP_INT_DOWNWARD, \ + FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO, \ + FP_INT_TONEAREST, UNKNOWN_MATH_ROUNDING_DIRECTION, \ + }; + +namespace LIBC_NAMESPACE::testing { + +template +struct FPTest : public ErrnoSafeTest, public FEnvSafeTest { + using FPBits = LIBC_NAMESPACE::fputil::FPBits; + using StorageType = typename FPBits::StorageType; + static constexpr StorageType STORAGE_MAX = + LIBC_NAMESPACE::cpp::numeric_limits::max(); + static constexpr T zero = FPBits::zero(Sign::POS).get_val(); + static constexpr T neg_zero = FPBits::zero(Sign::NEG).get_val(); + static constexpr T aNaN = FPBits::quiet_nan().get_val(); + static constexpr T sNaN = FPBits::signaling_nan().get_val(); + static constexpr T inf = FPBits::inf(Sign::POS).get_val(); + static constexpr T neg_inf = FPBits::inf(Sign::NEG).get_val(); + static constexpr T min_normal = FPBits::min_normal().get_val(); + static constexpr T max_normal = FPBits::max_normal().get_val(); + static constexpr T min_denormal = FPBits::min_subnormal().get_val(); + static constexpr T max_denormal = FPBits::max_subnormal().get_val(); + + static constexpr int N_ROUNDING_MODES = 4; + static constexpr fputil::testing::RoundingMode ROUNDING_MODES[4] = { + fputil::testing::RoundingMode::Nearest, + fputil::testing::RoundingMode::Upward, + fputil::testing::RoundingMode::Downward, + fputil::testing::RoundingMode::TowardZero, + }; + + void TearDown() override { FEnvSafeTest::TearDown(); } + + void SetUp() override { ErrnoSafeTest::SetUp(); } +}; + +} // namespace LIBC_NAMESPACE::testing + +// Does not return the value of `expr_or_statement`, i.e., intended usage +// is: `EXPECT_ERRNO_FPEXC(EDOM, FE_INVALID, EXPECT_FP_EQ(..., ...));` or +// ``` +// EXPECT_ERRNO_FPEXC(EDOM, FE_INVALID, { +// stmt; +// ... +// }); +// ``` +// Ensures that fp excepts and errno are cleared before executing +// `expr_or_statement` Checking (expected_fexn = 0) ensures that no exceptions +// were set +#define EXPECT_ERRNO_FP_EXCEPTION(expected_errno, expected_fexn, \ + expr_or_statement) \ + EXPECT_FP_EXCEPTION((expected_fexn), EXPECT_ERRNO((expected_errno), { \ + expr_or_statement; \ + if (!(math_errhandling & MATH_ERRNO)) \ + break; \ + })) + +#define EXPECT_NO_ERRNO_FP_EXCEPTION(expr_or_statement) \ + EXPECT_ERRNO_FP_EXCEPTION(0, 0, expr_or_statement) + +#define EXPECT_ERRNO_FP_EXCEPTION_ALL_ROUNDING(expected_errno, expected_fexn, \ + expr_or_statement) \ + FOR_ALL_ROUNDING_(EXPECT_ERRNO_FP_EXCEPTION( \ + (expected_errno), (expected_fexn), expr_or_statement)) + +#define EXPECT_NO_ERRNO_FP_EXCEPTION_ALL_ROUNDING(expr_or_statement) \ + FOR_ALL_ROUNDING_(EXPECT_NO_ERRNO_FP_EXCEPTION(expr_or_statement)) + +#endif // LLVM_LIBC_TEST_UNITTEST_FPTEST_H diff --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h index bba3c6d743bece..0137d41abd0ce0 100644 --- a/libc/test/UnitTest/LibcTest.h +++ b/libc/test/UnitTest/LibcTest.h @@ -399,8 +399,9 @@ CString libc_make_test_file_path_func(const char *file_name); LIBC_NAMESPACE::testing::internal::Message() #define LIBC_TEST_BINOP_(COND, LHS, RHS, RET_OR_EMPTY) \ - LIBC_TEST_SCAFFOLDING_(test(LIBC_NAMESPACE::testing::TestCond::COND, LHS, \ - RHS, #LHS, #RHS, LIBC_TEST_LOC_()), \ + LIBC_TEST_SCAFFOLDING_(LIBC_NAMESPACE::testing::Test::test( \ + LIBC_NAMESPACE::testing::TestCond::COND, LHS, \ + RHS, #LHS, #RHS, LIBC_TEST_LOC_()), \ RET_OR_EMPTY) //////////////////////////////////////////////////////////////////////////////// @@ -473,9 +474,10 @@ CString libc_make_test_file_path_func(const char *file_name); // Custom matcher checks. #define LIBC_TEST_MATCH_(MATCHER, MATCH, MATCHER_STR, MATCH_STR, RET_OR_EMPTY) \ - LIBC_TEST_SCAFFOLDING_(matchAndExplain(MATCHER, MATCH, MATCHER_STR, \ - MATCH_STR, LIBC_TEST_LOC_()), \ - RET_OR_EMPTY) + LIBC_TEST_SCAFFOLDING_( \ + LIBC_NAMESPACE::testing::Test::matchAndExplain( \ + MATCHER, MATCH, MATCHER_STR, MATCH_STR, LIBC_TEST_LOC_()), \ + RET_OR_EMPTY) #define EXPECT_THAT(MATCH, MATCHER) \ LIBC_TEST_MATCH_(MATCHER, MATCH, #MATCHER, #MATCH, ) diff --git a/libc/test/src/__support/FPUtil/dyadic_float_test.cpp b/libc/test/src/__support/FPUtil/dyadic_float_test.cpp index 809381ed47b59b..32e2aabdadc9a9 100644 --- a/libc/test/src/__support/FPUtil/dyadic_float_test.cpp +++ b/libc/test/src/__support/FPUtil/dyadic_float_test.cpp @@ -8,7 +8,7 @@ #include "src/__support/FPUtil/dyadic_float.h" #include "src/__support/big_int.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/CeilTest.h b/libc/test/src/math/CeilTest.h index b4c3752cc5c4ba..6f2d883cb00e06 100644 --- a/libc/test/src/math/CeilTest.h +++ b/libc/test/src/math/CeilTest.h @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/CopySignTest.h b/libc/test/src/math/CopySignTest.h index c66f91477480b8..773b60c482d6b8 100644 --- a/libc/test/src/math/CopySignTest.h +++ b/libc/test/src/math/CopySignTest.h @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/FAbsTest.h b/libc/test/src/math/FAbsTest.h index 92b589beeb675f..bc417827208549 100644 --- a/libc/test/src/math/FAbsTest.h +++ b/libc/test/src/math/FAbsTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_FABSTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h index fefcefe5052a92..6693a0e4d006ba 100644 --- a/libc/test/src/math/FDimTest.h +++ b/libc/test/src/math/FDimTest.h @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/FMaxTest.h b/libc/test/src/math/FMaxTest.h index 405642c6b96841..12edd8717c382e 100644 --- a/libc/test/src/math/FMaxTest.h +++ b/libc/test/src/math/FMaxTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_FMAXTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/FMinTest.h b/libc/test/src/math/FMinTest.h index eae0008ddfe392..27a9b17bb7490c 100644 --- a/libc/test/src/math/FMinTest.h +++ b/libc/test/src/math/FMinTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_FMINTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h index 32c009ab88286d..68087c04ab9ba0 100644 --- a/libc/test/src/math/FModTest.h +++ b/libc/test/src/math/FModTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/NearestIntegerOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" @@ -21,7 +21,7 @@ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); \ EXPECT_FP_EQ(expected, f(x, y)); \ EXPECT_MATH_ERRNO((dom_err) ? EDOM : 0); \ - EXPECT_FP_EXCEPTION(expected_exception) + EXPECT_FP_EXCEPTION_HAPPENED(expected_exception) #define TEST_REGULAR(x, y, expected) TEST_SPECIAL(x, y, expected, false, 0) diff --git a/libc/test/src/math/FloorTest.h b/libc/test/src/math/FloorTest.h index 9103a5b05eb5ad..fe797fc70cb6cf 100644 --- a/libc/test/src/math/FloorTest.h +++ b/libc/test/src/math/FloorTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h index 5a40f694ebd107..436cfe93bd511f 100644 --- a/libc/test/src/math/FmaTest.h +++ b/libc/test/src/math/FmaTest.h @@ -13,7 +13,7 @@ #include "src/stdlib/rand.h" #include "src/stdlib/srand.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/FrexpTest.h b/libc/test/src/math/FrexpTest.h index 3ba64afa3c6205..075abd6e4b29f5 100644 --- a/libc/test/src/math/FrexpTest.h +++ b/libc/test/src/math/FrexpTest.h @@ -8,7 +8,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/HypotTest.h b/libc/test/src/math/HypotTest.h index 58b53383182459..69dbc01e521ae3 100644 --- a/libc/test/src/math/HypotTest.h +++ b/libc/test/src/math/HypotTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h index 34466a526d60fb..a9743c4691bff3 100644 --- a/libc/test/src/math/LdExpTest.h +++ b/libc/test/src/math/LdExpTest.h @@ -13,7 +13,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/NormalFloat.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/LogbTest.h b/libc/test/src/math/LogbTest.h index d6042e3c200c76..83c3463951031c 100644 --- a/libc/test/src/math/LogbTest.h +++ b/libc/test/src/math/LogbTest.h @@ -8,7 +8,7 @@ #include "src/__support/FPUtil/ManipulationFunctions.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h index d6c6f27a5edf66..15a3ebdb386f9a 100644 --- a/libc/test/src/math/ModfTest.h +++ b/libc/test/src/math/ModfTest.h @@ -9,7 +9,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/NearestIntegerOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h index b3b03f763992a0..c8038dd55c3bb2 100644 --- a/libc/test/src/math/NextAfterTest.h +++ b/libc/test/src/math/NextAfterTest.h @@ -15,7 +15,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h index 007b50427ba34a..b1cfad4c18ceb1 100644 --- a/libc/test/src/math/RIntTest.h +++ b/libc/test/src/math/RIntTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h index c39f2394555eac..a485e3434baa1d 100644 --- a/libc/test/src/math/RemQuoTest.h +++ b/libc/test/src/math/RemQuoTest.h @@ -13,7 +13,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/RoundEvenTest.h b/libc/test/src/math/RoundEvenTest.h index d70555d3476591..891c72fe436d11 100644 --- a/libc/test/src/math/RoundEvenTest.h +++ b/libc/test/src/math/RoundEvenTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/RoundTest.h b/libc/test/src/math/RoundTest.h index 2a31df305ac384..44e3ea21dfa402 100644 --- a/libc/test/src/math/RoundTest.h +++ b/libc/test/src/math/RoundTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h index d40e15080087c0..12ae804db30d4e 100644 --- a/libc/test/src/math/RoundToIntegerTest.h +++ b/libc/test/src/math/RoundToIntegerTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" @@ -62,7 +62,7 @@ class RoundToIntegerTestTemplate // all math functions using RoundToInteger test: // https://github.com/llvm/llvm-project/pull/88816 if (expectError) { - ASSERT_FP_EXCEPTION(FE_INVALID); + ASSERT_FP_EXCEPTION_HAPPENED(FE_INVALID); ASSERT_MATH_ERRNO(EDOM); } } diff --git a/libc/test/src/math/SqrtTest.h b/libc/test/src/math/SqrtTest.h index 1c422e201bb234..0cfa70d57a6efa 100644 --- a/libc/test/src/math/SqrtTest.h +++ b/libc/test/src/math/SqrtTest.h @@ -8,7 +8,7 @@ #include "src/__support/CPP/bit.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/TruncTest.h b/libc/test/src/math/TruncTest.h index bc5b76131291bb..cc0fd2065f2b9b 100644 --- a/libc/test/src/math/TruncTest.h +++ b/libc/test/src/math/TruncTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_TRUNCTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp index 0d25a808e0bf3c..a7c59709b91ec9 100644 --- a/libc/test/src/math/acosf_test.cpp +++ b/libc/test/src/math/acosf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/acosf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/acoshf_test.cpp b/libc/test/src/math/acoshf_test.cpp index 32761e25b5ce54..1bb3f1ba7e935f 100644 --- a/libc/test/src/math/acoshf_test.cpp +++ b/libc/test/src/math/acoshf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/acoshf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp index 91e61085e91b89..84e9d2ea506094 100644 --- a/libc/test/src/math/asinf_test.cpp +++ b/libc/test/src/math/asinf_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/asinf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp index b19e26efd07bf6..0780cafe8cc54b 100644 --- a/libc/test/src/math/asinhf_test.cpp +++ b/libc/test/src/math/asinhf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/asinhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/atan2f_test.cpp b/libc/test/src/math/atan2f_test.cpp index 1242b7e66528f0..28de5b9cacaa19 100644 --- a/libc/test/src/math/atan2f_test.cpp +++ b/libc/test/src/math/atan2f_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/atan2f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp index 376b4724b5a3a2..3715bbe81e8cdf 100644 --- a/libc/test/src/math/atanf_test.cpp +++ b/libc/test/src/math/atanf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/atanf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" @@ -29,21 +29,21 @@ TEST_F(LlvmLibcAtanfTest, SpecialNumbers) { EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanf(aNaN)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atanf(0.0f)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atanf(-0.0f)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); } diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp index b0505e4c1182a5..822afbbacbd288 100644 --- a/libc/test/src/math/atanhf_test.cpp +++ b/libc/test/src/math/atanhf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/atanhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" @@ -30,31 +30,31 @@ TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) { EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(aNaN)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atanhf(0.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atanhf(-0.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(inf, LIBC_NAMESPACE::atanhf(1.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(FE_DIVBYZERO); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_DIVBYZERO); EXPECT_MATH_ERRNO(ERANGE); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(neg_inf, LIBC_NAMESPACE::atanhf(-1.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(FE_DIVBYZERO); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_DIVBYZERO); EXPECT_MATH_ERRNO(ERANGE); auto bt = FPBits(1.0f); @@ -62,37 +62,37 @@ TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) { LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(bt.get_val())); - // EXPECT_FP_EXCEPTION(FE_INVALID); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_INVALID); EXPECT_MATH_ERRNO(EDOM); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); bt.set_sign(Sign::NEG); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(bt.get_val())); // See above TODO - // EXPECT_FP_EXCEPTION(FE_INVALID); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_INVALID); EXPECT_MATH_ERRNO(EDOM); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(2.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(FE_INVALID); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_INVALID); EXPECT_MATH_ERRNO(EDOM); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(-2.0f)); - // EXPECT_FP_EXCEPTION(FE_INVALID); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_INVALID); EXPECT_MATH_ERRNO(EDOM); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(inf)); // See above TODO - // EXPECT_FP_EXCEPTION(FE_INVALID); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_INVALID); EXPECT_MATH_ERRNO(EDOM); bt.set_sign(Sign::NEG); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(neg_inf)); // See above TODO - // EXPECT_FP_EXCEPTION(FE_INVALID); + // EXPECT_FP_EXCEPTION_HAPPENED(FE_INVALID); EXPECT_MATH_ERRNO(EDOM); } diff --git a/libc/test/src/math/cos_test.cpp b/libc/test/src/math/cos_test.cpp index 9a39616ed16f81..58f80b16f7310e 100644 --- a/libc/test/src/math/cos_test.cpp +++ b/libc/test/src/math/cos_test.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "src/math/cos.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp index dab35fa1a9fe76..8e005426e1ca5c 100644 --- a/libc/test/src/math/cosf_test.cpp +++ b/libc/test/src/math/cosf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/cosf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "test/src/math/sdcomp26094.h" #include "utils/MPFRWrapper/MPFRUtils.h" @@ -24,22 +24,17 @@ using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest; namespace mpfr = LIBC_NAMESPACE::testing::mpfr; TEST_F(LlvmLibcCosfTest, SpecialNumbers) { - LIBC_NAMESPACE::libc_errno = 0; + EXPECT_NO_ERRNO_FP_EXCEPTION(EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(aNaN))); - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(aNaN)); - EXPECT_MATH_ERRNO(0); + EXPECT_NO_ERRNO_FP_EXCEPTION(EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cosf(0.0f))); - EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cosf(0.0f)); - EXPECT_MATH_ERRNO(0); + EXPECT_NO_ERRNO_FP_EXCEPTION(EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cosf(-0.0f))); - EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cosf(-0.0f)); - EXPECT_MATH_ERRNO(0); + EXPECT_ERRNO_FP_EXCEPTION(EDOM, FE_INVALID, + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(inf))); - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(inf)); - EXPECT_MATH_ERRNO(EDOM); - - EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(neg_inf)); - EXPECT_MATH_ERRNO(EDOM); + EXPECT_ERRNO_FP_EXCEPTION(EDOM, FE_INVALID, + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(neg_inf))); } TEST_F(LlvmLibcCosfTest, InFloatRange) { diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp index 7c5d6630e10938..711596fb5c380d 100644 --- a/libc/test/src/math/coshf_test.cpp +++ b/libc/test/src/math/coshf_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/coshf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/erff_test.cpp b/libc/test/src/math/erff_test.cpp index 5c848d7d5bf7d5..405e1be3950922 100644 --- a/libc/test/src/math/erff_test.cpp +++ b/libc/test/src/math/erff_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/erff.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exhaustive/exhaustive_test.h b/libc/test/src/math/exhaustive/exhaustive_test.h index c4ae382688a03c..0bbf79c93dd6a1 100644 --- a/libc/test/src/math/exhaustive/exhaustive_test.h +++ b/libc/test/src/math/exhaustive/exhaustive_test.h @@ -8,7 +8,7 @@ #include "src/__support/CPP/type_traits.h" #include "src/__support/FPUtil/FPBits.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp b/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp index b064b7e37f428d..06f5c904ac243f 100644 --- a/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp +++ b/libc/test/src/math/exhaustive/fmod_generic_impl_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/ManipulationFunctions.h" // ldexp #include "src/__support/FPUtil/generic/FMod.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exhaustive/hypotf_test.cpp b/libc/test/src/math/exhaustive/hypotf_test.cpp index 04da55d4d3a9fc..05b1b305b688ac 100644 --- a/libc/test/src/math/exhaustive/hypotf_test.cpp +++ b/libc/test/src/math/exhaustive/hypotf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/Hypot.h" #include "src/math/hypotf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "utils/MPFRWrapper/MPFRUtils.h" namespace mpfr = LIBC_NAMESPACE::testing::mpfr; diff --git a/libc/test/src/math/exp10_test.cpp b/libc/test/src/math/exp10_test.cpp index 4cbdd169d80321..01fec31ef075ce 100644 --- a/libc/test/src/math/exp10_test.cpp +++ b/libc/test/src/math/exp10_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp10.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp index e9b27866810423..602f52f8b85973 100644 --- a/libc/test/src/math/exp10f_test.cpp +++ b/libc/test/src/math/exp10f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp10f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exp2_test.cpp b/libc/test/src/math/exp2_test.cpp index 73232ed36077b8..aeeab350e1201d 100644 --- a/libc/test/src/math/exp2_test.cpp +++ b/libc/test/src/math/exp2_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp2.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp index 8ff0ce6a6e7245..10a122fb5399af 100644 --- a/libc/test/src/math/exp2f_test.cpp +++ b/libc/test/src/math/exp2f_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA #include "src/errno/libc_errno.h" #include "src/math/exp2f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exp2m1f_test.cpp b/libc/test/src/math/exp2m1f_test.cpp index cb948289b6179c..1b5ac8a8a69706 100644 --- a/libc/test/src/math/exp2m1f_test.cpp +++ b/libc/test/src/math/exp2m1f_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp2m1f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/exp_test.cpp b/libc/test/src/math/exp_test.cpp index 64d8198e64f2de..07a2de9f127ac1 100644 --- a/libc/test/src/math/exp_test.cpp +++ b/libc/test/src/math/exp_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp index 1dce381918eb65..e24a830ba87fbd 100644 --- a/libc/test/src/math/expf_test.cpp +++ b/libc/test/src/math/expf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/expf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/explogxf_test.cpp b/libc/test/src/math/explogxf_test.cpp index bcca87f590d759..918eedccce4488 100644 --- a/libc/test/src/math/explogxf_test.cpp +++ b/libc/test/src/math/explogxf_test.cpp @@ -12,7 +12,7 @@ #include "src/math/fabs.h" #include "src/math/fabsf.h" #include "src/math/generic/explogxf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/expm1_test.cpp b/libc/test/src/math/expm1_test.cpp index 1bf07f19f3a7c6..a0693cf65f8af3 100644 --- a/libc/test/src/math/expm1_test.cpp +++ b/libc/test/src/math/expm1_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/expm1.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp index 515f988b62649f..292bdd36cfc2ee 100644 --- a/libc/test/src/math/expm1f_test.cpp +++ b/libc/test/src/math/expm1f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/expm1f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/fdim_test.cpp b/libc/test/src/math/fdim_test.cpp index 1e8adf036ddeaf..fafb4906cdfc7d 100644 --- a/libc/test/src/math/fdim_test.cpp +++ b/libc/test/src/math/fdim_test.cpp @@ -11,7 +11,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/fdim.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" using LlvmLibcFDimTest = FDimTestTemplate; diff --git a/libc/test/src/math/fdimf_test.cpp b/libc/test/src/math/fdimf_test.cpp index 13e61d9082da42..a59801e952abfa 100644 --- a/libc/test/src/math/fdimf_test.cpp +++ b/libc/test/src/math/fdimf_test.cpp @@ -11,7 +11,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/fdimf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" using LlvmLibcFDimTest = FDimTestTemplate; diff --git a/libc/test/src/math/fdiml_test.cpp b/libc/test/src/math/fdiml_test.cpp index 2d99d2134c1c03..ce296d509d30c2 100644 --- a/libc/test/src/math/fdiml_test.cpp +++ b/libc/test/src/math/fdiml_test.cpp @@ -11,7 +11,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/fdiml.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" using LlvmLibcFDimTest = FDimTestTemplate; diff --git a/libc/test/src/math/ilogb_test.cpp b/libc/test/src/math/ilogb_test.cpp index c8daf2e0adafe1..2c11efb7cb2a37 100644 --- a/libc/test/src/math/ilogb_test.cpp +++ b/libc/test/src/math/ilogb_test.cpp @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/ManipulationFunctions.h" #include "src/math/ilogb.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogb) { diff --git a/libc/test/src/math/ilogbf_test.cpp b/libc/test/src/math/ilogbf_test.cpp index 87a2789f6c1106..c1227a438365c8 100644 --- a/libc/test/src/math/ilogbf_test.cpp +++ b/libc/test/src/math/ilogbf_test.cpp @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/ManipulationFunctions.h" #include "src/math/ilogbf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogbf) { diff --git a/libc/test/src/math/ilogbl_test.cpp b/libc/test/src/math/ilogbl_test.cpp index 042a803b024a7e..b0214715721964 100644 --- a/libc/test/src/math/ilogbl_test.cpp +++ b/libc/test/src/math/ilogbl_test.cpp @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/ManipulationFunctions.h" #include "src/math/ilogbl.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" TEST_F(LlvmLibcILogbTest, SpecialNumbers_ilogbl) { diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp index fd9a615ca87f71..90db3bc9325088 100644 --- a/libc/test/src/math/log10_test.cpp +++ b/libc/test/src/math/log10_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log10.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/log10f_test.cpp b/libc/test/src/math/log10f_test.cpp index 4ba118455df4dd..1c99c9408eb700 100644 --- a/libc/test/src/math/log10f_test.cpp +++ b/libc/test/src/math/log10f_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/log10f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp index 47dfa406ec257c..7e8e7dfb6eace9 100644 --- a/libc/test/src/math/log1p_test.cpp +++ b/libc/test/src/math/log1p_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log1p.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp index db0772d3c8b878..7e854029d32076 100644 --- a/libc/test/src/math/log1pf_test.cpp +++ b/libc/test/src/math/log1pf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log1pf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp index 9992c1340e99dc..7121cd3d4cf716 100644 --- a/libc/test/src/math/log2_test.cpp +++ b/libc/test/src/math/log2_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log2.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/log2f_test.cpp b/libc/test/src/math/log2f_test.cpp index 24b51adac94d17..8b1f1b69e0d12f 100644 --- a/libc/test/src/math/log2f_test.cpp +++ b/libc/test/src/math/log2f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log2f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/log_test.cpp b/libc/test/src/math/log_test.cpp index de1e59579419e5..7e8a1088e83e55 100644 --- a/libc/test/src/math/log_test.cpp +++ b/libc/test/src/math/log_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/logf_test.cpp b/libc/test/src/math/logf_test.cpp index 28a171d540665c..659665902bb239 100644 --- a/libc/test/src/math/logf_test.cpp +++ b/libc/test/src/math/logf_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/logf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/powf_test.cpp b/libc/test/src/math/powf_test.cpp index 69135593cd32c4..acd850e4939483 100644 --- a/libc/test/src/math/powf_test.cpp +++ b/libc/test/src/math/powf_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/powf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/sin_test.cpp b/libc/test/src/math/sin_test.cpp index 0171b79810d4e9..54f6bcd6cd28d4 100644 --- a/libc/test/src/math/sin_test.cpp +++ b/libc/test/src/math/sin_test.cpp @@ -8,7 +8,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/math/sin.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp index 7c359b345f4c3a..8c988a7e415173 100644 --- a/libc/test/src/math/sincosf_test.cpp +++ b/libc/test/src/math/sincosf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/sincosf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "test/src/math/sdcomp26094.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp index 6a8f8f4ee4288c..fb7e8730a875d4 100644 --- a/libc/test/src/math/sinf_test.cpp +++ b/libc/test/src/math/sinf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/sinf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "test/src/math/sdcomp26094.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp index cc0552f728947a..05df910df2b06f 100644 --- a/libc/test/src/math/sinhf_test.cpp +++ b/libc/test/src/math/sinhf_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/sinhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/smoke/CanonicalizeTest.h b/libc/test/src/math/smoke/CanonicalizeTest.h index 7e2456f84705c9..c4c66ee0d7e4e3 100644 --- a/libc/test/src/math/smoke/CanonicalizeTest.h +++ b/libc/test/src/math/smoke/CanonicalizeTest.h @@ -12,14 +12,14 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/integer_literals.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" #define TEST_SPECIAL(x, y, expected, expected_exception) \ EXPECT_EQ(expected, f(&x, &y)); \ - EXPECT_FP_EXCEPTION(expected_exception); \ + EXPECT_FP_EXCEPTION_HAPPENED(expected_exception); \ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT) #define TEST_REGULAR(x, y, expected) TEST_SPECIAL(x, y, expected, 0) diff --git a/libc/test/src/math/smoke/CeilTest.h b/libc/test/src/math/smoke/CeilTest.h index 5e108c0e0feea1..7ae4587fc665da 100644 --- a/libc/test/src/math/smoke/CeilTest.h +++ b/libc/test/src/math/smoke/CeilTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_CEILTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/CopySignTest.h b/libc/test/src/math/smoke/CopySignTest.h index 1810560bf1bb8f..7af9a91de13b55 100644 --- a/libc/test/src/math/smoke/CopySignTest.h +++ b/libc/test/src/math/smoke/CopySignTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_COPYSIGNTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/FAbsTest.h b/libc/test/src/math/smoke/FAbsTest.h index 048023b414299f..359869a3d0884f 100644 --- a/libc/test/src/math/smoke/FAbsTest.h +++ b/libc/test/src/math/smoke/FAbsTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FABSTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/FDimTest.h b/libc/test/src/math/smoke/FDimTest.h index cff88f29a8efa8..76d0c099539918 100644 --- a/libc/test/src/math/smoke/FDimTest.h +++ b/libc/test/src/math/smoke/FDimTest.h @@ -9,7 +9,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMaxTest.h b/libc/test/src/math/smoke/FMaxTest.h index df8e35e0bd1620..51fab4f8ed9c48 100644 --- a/libc/test/src/math/smoke/FMaxTest.h +++ b/libc/test/src/math/smoke/FMaxTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMaximumMagNumTest.h b/libc/test/src/math/smoke/FMaximumMagNumTest.h index aafb6d2b0d5eac..78005bda343120 100644 --- a/libc/test/src/math/smoke/FMaximumMagNumTest.h +++ b/libc/test/src/math/smoke/FMaximumMagNumTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMaximumMagTest.h b/libc/test/src/math/smoke/FMaximumMagTest.h index 7bb79a69be580f..1587864e2c9b0d 100644 --- a/libc/test/src/math/smoke/FMaximumMagTest.h +++ b/libc/test/src/math/smoke/FMaximumMagTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMaximumNumTest.h b/libc/test/src/math/smoke/FMaximumNumTest.h index da0ea2c247a9ee..b7de3490bf9803 100644 --- a/libc/test/src/math/smoke/FMaximumNumTest.h +++ b/libc/test/src/math/smoke/FMaximumNumTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMaximumTest.h b/libc/test/src/math/smoke/FMaximumTest.h index 1bd15163ed7529..e9792cdebf4fc6 100644 --- a/libc/test/src/math/smoke/FMaximumTest.h +++ b/libc/test/src/math/smoke/FMaximumTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMinTest.h b/libc/test/src/math/smoke/FMinTest.h index f71b558cd3da20..72e942457698dd 100644 --- a/libc/test/src/math/smoke/FMinTest.h +++ b/libc/test/src/math/smoke/FMinTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMinimumMagNumTest.h b/libc/test/src/math/smoke/FMinimumMagNumTest.h index e4b8fd9e335311..c89c8b7e496f15 100644 --- a/libc/test/src/math/smoke/FMinimumMagNumTest.h +++ b/libc/test/src/math/smoke/FMinimumMagNumTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMinimumMagTest.h b/libc/test/src/math/smoke/FMinimumMagTest.h index 3e16622fe3fa41..febebf2a0fded6 100644 --- a/libc/test/src/math/smoke/FMinimumMagTest.h +++ b/libc/test/src/math/smoke/FMinimumMagTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMinimumNumTest.h b/libc/test/src/math/smoke/FMinimumNumTest.h index 6186ea0df17cce..ea7cfe7ab3ee02 100644 --- a/libc/test/src/math/smoke/FMinimumNumTest.h +++ b/libc/test/src/math/smoke/FMinimumNumTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FMinimumTest.h b/libc/test/src/math/smoke/FMinimumTest.h index a267f6c7832145..736079d1228a29 100644 --- a/libc/test/src/math/smoke/FMinimumTest.h +++ b/libc/test/src/math/smoke/FMinimumTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h index f1015d6497fcd6..dd98001ab5bea2 100644 --- a/libc/test/src/math/smoke/FModTest.h +++ b/libc/test/src/math/smoke/FModTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/NearestIntegerOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" @@ -20,7 +20,7 @@ #define TEST_SPECIAL(x, y, expected, dom_err, expected_exception) \ EXPECT_FP_EQ(expected, f(x, y)); \ EXPECT_MATH_ERRNO((dom_err) ? EDOM : 0); \ - EXPECT_FP_EXCEPTION(expected_exception); \ + EXPECT_FP_EXCEPTION_HAPPENED(expected_exception); \ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT) #define TEST_REGULAR(x, y, expected) TEST_SPECIAL(x, y, expected, false, 0) diff --git a/libc/test/src/math/smoke/FloorTest.h b/libc/test/src/math/smoke/FloorTest.h index b2102459bc3de6..986a465e3ee80b 100644 --- a/libc/test/src/math/smoke/FloorTest.h +++ b/libc/test/src/math/smoke/FloorTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FLOORTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/FmaTest.h b/libc/test/src/math/smoke/FmaTest.h index 7063ecf199837b..4aadaf0f5e677d 100644 --- a/libc/test/src/math/smoke/FmaTest.h +++ b/libc/test/src/math/smoke/FmaTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FrexpTest.h b/libc/test/src/math/smoke/FrexpTest.h index e9e496422f7326..d690fed1d21836 100644 --- a/libc/test/src/math/smoke/FrexpTest.h +++ b/libc/test/src/math/smoke/FrexpTest.h @@ -8,7 +8,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FromfpTest.h b/libc/test/src/math/smoke/FromfpTest.h index f19f21ce47e7f9..066d64ff11bf2f 100644 --- a/libc/test/src/math/smoke/FromfpTest.h +++ b/libc/test/src/math/smoke/FromfpTest.h @@ -10,7 +10,7 @@ #define LIBC_TEST_SRC_MATH_SMOKE_FROMFPTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/FromfpxTest.h b/libc/test/src/math/smoke/FromfpxTest.h index 4aa47a68bb1783..a605f494af4b6a 100644 --- a/libc/test/src/math/smoke/FromfpxTest.h +++ b/libc/test/src/math/smoke/FromfpxTest.h @@ -10,7 +10,7 @@ #define LIBC_TEST_SRC_MATH_SMOKE_FROMFPXTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/HypotTest.h b/libc/test/src/math/smoke/HypotTest.h index 80e9bb7366dfea..b33cf3c6acdc9e 100644 --- a/libc/test/src/math/smoke/HypotTest.h +++ b/libc/test/src/math/smoke/HypotTest.h @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/LdExpTest.h b/libc/test/src/math/smoke/LdExpTest.h index 713d305c47494a..e82d11959c900f 100644 --- a/libc/test/src/math/smoke/LdExpTest.h +++ b/libc/test/src/math/smoke/LdExpTest.h @@ -13,7 +13,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/NormalFloat.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/LogbTest.h b/libc/test/src/math/smoke/LogbTest.h index 4938fcf8f6f16e..b775deaca56a3c 100644 --- a/libc/test/src/math/smoke/LogbTest.h +++ b/libc/test/src/math/smoke/LogbTest.h @@ -8,7 +8,7 @@ #include "src/__support/FPUtil/ManipulationFunctions.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/ModfTest.h b/libc/test/src/math/smoke/ModfTest.h index 85db2d6d967b20..cff956f7a30191 100644 --- a/libc/test/src/math/smoke/ModfTest.h +++ b/libc/test/src/math/smoke/ModfTest.h @@ -9,7 +9,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/NearestIntegerOperations.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/NearbyIntTest.h b/libc/test/src/math/smoke/NearbyIntTest.h index 0051ff9447a7ed..4e253a1c2d35f7 100644 --- a/libc/test/src/math/smoke/NearbyIntTest.h +++ b/libc/test/src/math/smoke/NearbyIntTest.h @@ -12,7 +12,7 @@ #include "hdr/fenv_macros.h" #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO, diff --git a/libc/test/src/math/smoke/NextAfterTest.h b/libc/test/src/math/smoke/NextAfterTest.h index d65ccdf8e70c3a..63a2044dead48c 100644 --- a/libc/test/src/math/smoke/NextAfterTest.h +++ b/libc/test/src/math/smoke/NextAfterTest.h @@ -15,14 +15,14 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" // TODO: Strengthen errno,exception checks and remove these assert macros // after new matchers/test fixtures are added #define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \ ASSERT_FP_EQ(result, expected); \ - ASSERT_FP_EXCEPTION(expected_exception); \ + ASSERT_FP_EXCEPTION_HAPPENED(expected_exception); \ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT) #define ASSERT_FP_EQ_WITH_UNDERFLOW(result, expected) \ diff --git a/libc/test/src/math/smoke/NextDownTest.h b/libc/test/src/math/smoke/NextDownTest.h index b54c6d5763222f..b1335372b01791 100644 --- a/libc/test/src/math/smoke/NextDownTest.h +++ b/libc/test/src/math/smoke/NextDownTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/NextTowardTest.h b/libc/test/src/math/smoke/NextTowardTest.h index a24ec9ff6bd816..a3fb7cbbacaa4a 100644 --- a/libc/test/src/math/smoke/NextTowardTest.h +++ b/libc/test/src/math/smoke/NextTowardTest.h @@ -16,14 +16,14 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" // TODO: Strengthen errno,exception checks and remove these assert macros // after new matchers/test fixtures are added #define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \ ASSERT_FP_EQ(result, expected); \ - ASSERT_FP_EXCEPTION(expected_exception); \ + ASSERT_FP_EXCEPTION_HAPPENED(expected_exception); \ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT) #define ASSERT_FP_EQ_WITH_UNDERFLOW(result, expected) \ diff --git a/libc/test/src/math/smoke/NextUpTest.h b/libc/test/src/math/smoke/NextUpTest.h index 7f66c115dfc2dc..7097988ab765bc 100644 --- a/libc/test/src/math/smoke/NextUpTest.h +++ b/libc/test/src/math/smoke/NextUpTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_NEXTUPTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/RIntTest.h b/libc/test/src/math/smoke/RIntTest.h index 1412c3f27a2d5f..b3fea9a5866a70 100644 --- a/libc/test/src/math/smoke/RIntTest.h +++ b/libc/test/src/math/smoke/RIntTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/fenv_macros.h" diff --git a/libc/test/src/math/smoke/RemQuoTest.h b/libc/test/src/math/smoke/RemQuoTest.h index 43eee3d38e4495..76ee6ccb16aa00 100644 --- a/libc/test/src/math/smoke/RemQuoTest.h +++ b/libc/test/src/math/smoke/RemQuoTest.h @@ -13,7 +13,7 @@ #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/RoundEvenTest.h b/libc/test/src/math/smoke/RoundEvenTest.h index 479b70912fedc9..20dced8e5d5f4a 100644 --- a/libc/test/src/math/smoke/RoundEvenTest.h +++ b/libc/test/src/math/smoke/RoundEvenTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDEVENTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/RoundTest.h b/libc/test/src/math/smoke/RoundTest.h index 36994f27eb4c05..89cdeb974f078e 100644 --- a/libc/test/src/math/smoke/RoundTest.h +++ b/libc/test/src/math/smoke/RoundTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/RoundToIntegerTest.h b/libc/test/src/math/smoke/RoundToIntegerTest.h index 3ff311f46b056c..800f8c6aefaeca 100644 --- a/libc/test/src/math/smoke/RoundToIntegerTest.h +++ b/libc/test/src/math/smoke/RoundToIntegerTest.h @@ -12,7 +12,7 @@ #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" @@ -50,7 +50,7 @@ class RoundToIntegerTestTemplate // all math functions using RoundToInteger test: // https://github.com/llvm/llvm-project/pull/88816 if (expectError) { - ASSERT_FP_EXCEPTION(FE_INVALID); + ASSERT_FP_EXCEPTION_HAPPENED(FE_INVALID); ASSERT_MATH_ERRNO(EDOM); } } diff --git a/libc/test/src/math/smoke/SqrtTest.h b/libc/test/src/math/smoke/SqrtTest.h index 8afacaf01ae428..b6ae9b4ef4f05c 100644 --- a/libc/test/src/math/smoke/SqrtTest.h +++ b/libc/test/src/math/smoke/SqrtTest.h @@ -8,7 +8,7 @@ #include "src/__support/CPP/bit.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/TruncTest.h b/libc/test/src/math/smoke/TruncTest.h index 1d9c44dfb37488..03f8af88c6d60e 100644 --- a/libc/test/src/math/smoke/TruncTest.h +++ b/libc/test/src/math/smoke/TruncTest.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_TRUNCTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "hdr/math_macros.h" diff --git a/libc/test/src/math/smoke/UfromfpTest.h b/libc/test/src/math/smoke/UfromfpTest.h index 1c04049ebb4fa4..94309c70bdddf7 100644 --- a/libc/test/src/math/smoke/UfromfpTest.h +++ b/libc/test/src/math/smoke/UfromfpTest.h @@ -10,7 +10,7 @@ #define LIBC_TEST_SRC_MATH_SMOKE_UFROMFPTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/UfromfpxTest.h b/libc/test/src/math/smoke/UfromfpxTest.h index 973bc8a4d1be7b..61489b5957b85b 100644 --- a/libc/test/src/math/smoke/UfromfpxTest.h +++ b/libc/test/src/math/smoke/UfromfpxTest.h @@ -10,7 +10,7 @@ #define LIBC_TEST_SRC_MATH_SMOKE_UFROMFPXTEST_H #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" template diff --git a/libc/test/src/math/smoke/acosf_test.cpp b/libc/test/src/math/smoke/acosf_test.cpp index 732c29548c60d3..cc61f7f38878e8 100644 --- a/libc/test/src/math/smoke/acosf_test.cpp +++ b/libc/test/src/math/smoke/acosf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/acosf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/acoshf_test.cpp b/libc/test/src/math/smoke/acoshf_test.cpp index 2e94216ede364b..8574eae57d8fe4 100644 --- a/libc/test/src/math/smoke/acoshf_test.cpp +++ b/libc/test/src/math/smoke/acoshf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/acoshf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/asinf_test.cpp b/libc/test/src/math/smoke/asinf_test.cpp index c67d07711cd132..6ef53cd6893197 100644 --- a/libc/test/src/math/smoke/asinf_test.cpp +++ b/libc/test/src/math/smoke/asinf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/asinf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/asinhf_test.cpp b/libc/test/src/math/smoke/asinhf_test.cpp index f95184676303d6..b1acaa03b3b795 100644 --- a/libc/test/src/math/smoke/asinhf_test.cpp +++ b/libc/test/src/math/smoke/asinhf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/asinhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/atan2f_test.cpp b/libc/test/src/math/smoke/atan2f_test.cpp index 32a28cfdfeaa62..64edeb7de843ed 100644 --- a/libc/test/src/math/smoke/atan2f_test.cpp +++ b/libc/test/src/math/smoke/atan2f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/atan2f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" using LlvmLibcAtan2fTest = LIBC_NAMESPACE::testing::FPTest; @@ -25,36 +25,36 @@ TEST_F(LlvmLibcAtan2fTest, SpecialNumbers) { EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atan2f(aNaN, zero)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atan2f(1.0f, aNaN)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atan2f(zero, zero)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atan2f(-0.0f, zero)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atan2f(1.0f, inf)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atan2f(-1.0f, inf)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); } diff --git a/libc/test/src/math/smoke/atanf_test.cpp b/libc/test/src/math/smoke/atanf_test.cpp index 56bf2f951b3361..8aef378a02ab2f 100644 --- a/libc/test/src/math/smoke/atanf_test.cpp +++ b/libc/test/src/math/smoke/atanf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/atanf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include @@ -28,18 +28,18 @@ TEST_F(LlvmLibcAtanfTest, SpecialNumbers) { EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanf(aNaN)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atanf(0.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atanf(-0.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); } diff --git a/libc/test/src/math/smoke/atanhf_test.cpp b/libc/test/src/math/smoke/atanhf_test.cpp index 2d2acfeeab4e5e..72002b7cd25eac 100644 --- a/libc/test/src/math/smoke/atanhf_test.cpp +++ b/libc/test/src/math/smoke/atanhf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/atanhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include @@ -28,19 +28,19 @@ TEST_F(LlvmLibcAtanhfTest, SpecialNumbers) { EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::atanhf(aNaN)); // TODO: Uncomment these checks later, RoundingMode affects running // tests in this way https://github.com/llvm/llvm-project/issues/90653. - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(0.0f, LIBC_NAMESPACE::atanhf(0.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); EXPECT_FP_EQ_ALL_ROUNDING(-0.0f, LIBC_NAMESPACE::atanhf(-0.0f)); // See above TODO - // EXPECT_FP_EXCEPTION(0); + // EXPECT_FP_EXCEPTION_HAPPENED(0); EXPECT_MATH_ERRNO(0); EXPECT_FP_EQ_WITH_EXCEPTION(inf, LIBC_NAMESPACE::atanhf(1.0f), FE_DIVBYZERO); diff --git a/libc/test/src/math/smoke/cosf_test.cpp b/libc/test/src/math/smoke/cosf_test.cpp index 7000fe2f2b07de..4cbdc923dc6b11 100644 --- a/libc/test/src/math/smoke/cosf_test.cpp +++ b/libc/test/src/math/smoke/cosf_test.cpp @@ -10,8 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/cosf.h" -#include "test/UnitTest/FPMatcher.h" -#include "test/UnitTest/Test.h" +#include "test/UnitTest/FPTest.h" #include #include @@ -19,20 +18,17 @@ using LlvmLibcCosfTest = LIBC_NAMESPACE::testing::FPTest; TEST_F(LlvmLibcCosfTest, SpecialNumbers) { - LIBC_NAMESPACE::libc_errno = 0; + EXPECT_NO_ERRNO_FP_EXCEPTION(EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(aNaN))); - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::cosf(aNaN)); - EXPECT_MATH_ERRNO(0); + EXPECT_NO_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cosf(0.0f))); - EXPECT_FP_EQ_ALL_ROUNDING(1.0f, LIBC_NAMESPACE::cosf(0.0f)); - EXPECT_MATH_ERRNO(0); + EXPECT_NO_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::cosf(-0.0f))); - EXPECT_FP_EQ_ALL_ROUNDING(1.0f, LIBC_NAMESPACE::cosf(-0.0f)); - EXPECT_MATH_ERRNO(0); + EXPECT_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + EDOM, FE_INVALID, EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(inf))); - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::cosf(inf)); - EXPECT_MATH_ERRNO(EDOM); - - EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::cosf(neg_inf)); - EXPECT_MATH_ERRNO(EDOM); + EXPECT_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + EDOM, FE_INVALID, EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::cosf(neg_inf))); } diff --git a/libc/test/src/math/smoke/coshf_test.cpp b/libc/test/src/math/smoke/coshf_test.cpp index 4d915b12dee164..fe81541cb31908 100644 --- a/libc/test/src/math/smoke/coshf_test.cpp +++ b/libc/test/src/math/smoke/coshf_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/coshf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/erff_test.cpp b/libc/test/src/math/smoke/erff_test.cpp index 102126ee4e23fe..da87e5d23651c4 100644 --- a/libc/test/src/math/smoke/erff_test.cpp +++ b/libc/test/src/math/smoke/erff_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/erff.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/exp10_test.cpp b/libc/test/src/math/smoke/exp10_test.cpp index 7154cb176038c2..12ffe7bb22c608 100644 --- a/libc/test/src/math/smoke/exp10_test.cpp +++ b/libc/test/src/math/smoke/exp10_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp10.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/exp10f_test.cpp b/libc/test/src/math/smoke/exp10f_test.cpp index 9fb15ae75348bb..43fbf6fa8551cd 100644 --- a/libc/test/src/math/smoke/exp10f_test.cpp +++ b/libc/test/src/math/smoke/exp10f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp10f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/exp2_test.cpp b/libc/test/src/math/smoke/exp2_test.cpp index a8ef6cfa7f6a12..1969a578cc7002 100644 --- a/libc/test/src/math/smoke/exp2_test.cpp +++ b/libc/test/src/math/smoke/exp2_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp2.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/exp2f_test.cpp b/libc/test/src/math/smoke/exp2f_test.cpp index 3ef1a4ece4cf63..cba9198a1c9961 100644 --- a/libc/test/src/math/smoke/exp2f_test.cpp +++ b/libc/test/src/math/smoke/exp2f_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA #include "src/errno/libc_errno.h" #include "src/math/exp2f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/exp2m1f_test.cpp b/libc/test/src/math/smoke/exp2m1f_test.cpp index 2df43538524728..994dcd2baa989b 100644 --- a/libc/test/src/math/smoke/exp2m1f_test.cpp +++ b/libc/test/src/math/smoke/exp2m1f_test.cpp @@ -8,7 +8,7 @@ #include "src/errno/libc_errno.h" #include "src/math/exp2m1f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" using LlvmLibcExp2m1fTest = LIBC_NAMESPACE::testing::FPTest; diff --git a/libc/test/src/math/smoke/exp_test.cpp b/libc/test/src/math/smoke/exp_test.cpp index 2abaa7230831f2..8c6c03efd7280f 100644 --- a/libc/test/src/math/smoke/exp_test.cpp +++ b/libc/test/src/math/smoke/exp_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/exp.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/expf_test.cpp b/libc/test/src/math/smoke/expf_test.cpp index b954125afd7bba..048cddd0f92455 100644 --- a/libc/test/src/math/smoke/expf_test.cpp +++ b/libc/test/src/math/smoke/expf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/expf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/expm1_test.cpp b/libc/test/src/math/smoke/expm1_test.cpp index d5f166d53a50eb..a5c4d3fff61990 100644 --- a/libc/test/src/math/smoke/expm1_test.cpp +++ b/libc/test/src/math/smoke/expm1_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/expm1.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/expm1f_test.cpp b/libc/test/src/math/smoke/expm1f_test.cpp index 03b6e47b7c3bc4..51fa15a1653aea 100644 --- a/libc/test/src/math/smoke/expm1f_test.cpp +++ b/libc/test/src/math/smoke/expm1f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/expm1f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log10_test.cpp b/libc/test/src/math/smoke/log10_test.cpp index 37baf89128f2ec..e8ce7b76f93abd 100644 --- a/libc/test/src/math/smoke/log10_test.cpp +++ b/libc/test/src/math/smoke/log10_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log10.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log10f_test.cpp b/libc/test/src/math/smoke/log10f_test.cpp index 721045d355da8c..babc9a26e923b7 100644 --- a/libc/test/src/math/smoke/log10f_test.cpp +++ b/libc/test/src/math/smoke/log10f_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/log10f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log1p_test.cpp b/libc/test/src/math/smoke/log1p_test.cpp index 993dbf8001df86..7a99b35551e50b 100644 --- a/libc/test/src/math/smoke/log1p_test.cpp +++ b/libc/test/src/math/smoke/log1p_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log1p.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log1pf_test.cpp b/libc/test/src/math/smoke/log1pf_test.cpp index 6127cc89a74216..c139300c948c65 100644 --- a/libc/test/src/math/smoke/log1pf_test.cpp +++ b/libc/test/src/math/smoke/log1pf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log1pf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log2_test.cpp b/libc/test/src/math/smoke/log2_test.cpp index b59767e668eb61..18cc2461fc8b1f 100644 --- a/libc/test/src/math/smoke/log2_test.cpp +++ b/libc/test/src/math/smoke/log2_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log2.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log2f_test.cpp b/libc/test/src/math/smoke/log2f_test.cpp index 00bfb7c4abad67..88fb93c11b1e3a 100644 --- a/libc/test/src/math/smoke/log2f_test.cpp +++ b/libc/test/src/math/smoke/log2f_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log2f.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/log_test.cpp b/libc/test/src/math/smoke/log_test.cpp index fd527dee50847c..a079fcc6256024 100644 --- a/libc/test/src/math/smoke/log_test.cpp +++ b/libc/test/src/math/smoke/log_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/log.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/logf_test.cpp b/libc/test/src/math/smoke/logf_test.cpp index a2720602761452..0927395a766dee 100644 --- a/libc/test/src/math/smoke/logf_test.cpp +++ b/libc/test/src/math/smoke/logf_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/logf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/nan_test.cpp b/libc/test/src/math/smoke/nan_test.cpp index 2ddef58325671f..02f7bcac58c627 100644 --- a/libc/test/src/math/smoke/nan_test.cpp +++ b/libc/test/src/math/smoke/nan_test.cpp @@ -9,7 +9,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/math/nan.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/nanf128_test.cpp b/libc/test/src/math/smoke/nanf128_test.cpp index 8c15c532ebcf4c..4c6b3ba6649b94 100644 --- a/libc/test/src/math/smoke/nanf128_test.cpp +++ b/libc/test/src/math/smoke/nanf128_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/uint128.h" #include "src/math/nanf128.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" class LlvmLibcNanf128Test : public LIBC_NAMESPACE::testing::FEnvSafeTest { diff --git a/libc/test/src/math/smoke/nanf_test.cpp b/libc/test/src/math/smoke/nanf_test.cpp index 71f888c610aafc..a802b2769248dc 100644 --- a/libc/test/src/math/smoke/nanf_test.cpp +++ b/libc/test/src/math/smoke/nanf_test.cpp @@ -9,7 +9,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/math/nanf.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/nanl_test.cpp b/libc/test/src/math/smoke/nanl_test.cpp index 7fff20b1e7be3c..f58348486cf6dc 100644 --- a/libc/test/src/math/smoke/nanl_test.cpp +++ b/libc/test/src/math/smoke/nanl_test.cpp @@ -9,7 +9,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/math/nanl.h" #include "test/UnitTest/FEnvSafeTest.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/powf_test.cpp b/libc/test/src/math/smoke/powf_test.cpp index 98a532f3468c73..877af88905e861 100644 --- a/libc/test/src/math/smoke/powf_test.cpp +++ b/libc/test/src/math/smoke/powf_test.cpp @@ -9,7 +9,7 @@ #include "hdr/math_macros.h" #include "src/__support/FPUtil/FPBits.h" #include "src/math/powf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/sincosf_test.cpp b/libc/test/src/math/smoke/sincosf_test.cpp index 8c35953240d8da..0872d8697cb9a5 100644 --- a/libc/test/src/math/smoke/sincosf_test.cpp +++ b/libc/test/src/math/smoke/sincosf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/sincosf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include @@ -19,31 +19,30 @@ using LlvmLibcSinCosfTest = LIBC_NAMESPACE::testing::FPTest; TEST_F(LlvmLibcSinCosfTest, SpecialNumbers) { - LIBC_NAMESPACE::libc_errno = 0; float sin, cos; - LIBC_NAMESPACE::sincosf(aNaN, &sin, &cos); + EXPECT_NO_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + LIBC_NAMESPACE::sincosf(aNaN, &sin, &cos)); EXPECT_FP_EQ(aNaN, cos); EXPECT_FP_EQ(aNaN, sin); - EXPECT_MATH_ERRNO(0); - LIBC_NAMESPACE::sincosf(0.0f, &sin, &cos); + EXPECT_NO_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + LIBC_NAMESPACE::sincosf(0.0f, &sin, &cos)); EXPECT_FP_EQ(1.0f, cos); EXPECT_FP_EQ(0.0f, sin); - EXPECT_MATH_ERRNO(0); - LIBC_NAMESPACE::sincosf(-0.0f, &sin, &cos); + EXPECT_NO_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + LIBC_NAMESPACE::sincosf(-0.0f, &sin, &cos)); EXPECT_FP_EQ(1.0f, cos); EXPECT_FP_EQ(-0.0f, sin); - EXPECT_MATH_ERRNO(0); - LIBC_NAMESPACE::sincosf(inf, &sin, &cos); + EXPECT_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + EDOM, FE_INVALID, LIBC_NAMESPACE::sincosf(inf, &sin, &cos)); EXPECT_FP_EQ(aNaN, cos); EXPECT_FP_EQ(aNaN, sin); - EXPECT_MATH_ERRNO(EDOM); - LIBC_NAMESPACE::sincosf(neg_inf, &sin, &cos); + EXPECT_ERRNO_FP_EXCEPTION_ALL_ROUNDING( + EDOM, FE_INVALID, LIBC_NAMESPACE::sincosf(neg_inf, &sin, &cos)); EXPECT_FP_EQ(aNaN, cos); EXPECT_FP_EQ(aNaN, sin); - EXPECT_MATH_ERRNO(EDOM); } diff --git a/libc/test/src/math/smoke/sinf_test.cpp b/libc/test/src/math/smoke/sinf_test.cpp index 9fc208dd545b2d..acdd9d02259013 100644 --- a/libc/test/src/math/smoke/sinf_test.cpp +++ b/libc/test/src/math/smoke/sinf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/sinf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/sinhf_test.cpp b/libc/test/src/math/smoke/sinhf_test.cpp index 1e052988eb2862..18e453903e9bbb 100644 --- a/libc/test/src/math/smoke/sinhf_test.cpp +++ b/libc/test/src/math/smoke/sinhf_test.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/sinhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/tanf_test.cpp b/libc/test/src/math/smoke/tanf_test.cpp index ab3f7c1aeb7e4e..ead9c45272e121 100644 --- a/libc/test/src/math/smoke/tanf_test.cpp +++ b/libc/test/src/math/smoke/tanf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/tanf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/smoke/tanhf_test.cpp b/libc/test/src/math/smoke/tanhf_test.cpp index ddae021d2bc423..91f3e00c56f6e1 100644 --- a/libc/test/src/math/smoke/tanhf_test.cpp +++ b/libc/test/src/math/smoke/tanhf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/tanhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include diff --git a/libc/test/src/math/tan_test.cpp b/libc/test/src/math/tan_test.cpp index d813dccc383692..4e33658e24d96e 100644 --- a/libc/test/src/math/tan_test.cpp +++ b/libc/test/src/math/tan_test.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "src/math/tan.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp index e624d30f1e00ff..b87c7474bb6929 100644 --- a/libc/test/src/math/tanf_test.cpp +++ b/libc/test/src/math/tanf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/tanf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "test/src/math/sdcomp26094.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp index c34efe8d733be4..5596c37a3e26d2 100644 --- a/libc/test/src/math/tanhf_test.cpp +++ b/libc/test/src/math/tanhf_test.cpp @@ -10,7 +10,7 @@ #include "src/__support/FPUtil/FPBits.h" #include "src/errno/libc_errno.h" #include "src/math/tanhf.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "utils/MPFRWrapper/MPFRUtils.h" diff --git a/libc/test/src/stdfix/ExpTest.h b/libc/test/src/stdfix/ExpTest.h index e588cebf621b90..d7ddc710a5965c 100644 --- a/libc/test/src/stdfix/ExpTest.h +++ b/libc/test/src/stdfix/ExpTest.h @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "src/__support/CPP/bit.h" diff --git a/libc/test/src/stdfix/ISqrtTest.h b/libc/test/src/stdfix/ISqrtTest.h index ddf292fdd083f3..50356ba8c8639c 100644 --- a/libc/test/src/stdfix/ISqrtTest.h +++ b/libc/test/src/stdfix/ISqrtTest.h @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" #include "src/__support/CPP/bit.h" diff --git a/libc/test/src/stdio/sscanf_test.cpp b/libc/test/src/stdio/sscanf_test.cpp index 741815bb151712..0f09159edb6547 100644 --- a/libc/test/src/stdio/sscanf_test.cpp +++ b/libc/test/src/stdio/sscanf_test.cpp @@ -13,7 +13,7 @@ #include // For EOF -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/Test.h" TEST(LlvmLibcSScanfTest, SimpleStringConv) { diff --git a/libc/test/src/stdlib/strtof_test.cpp b/libc/test/src/stdlib/strtof_test.cpp index d7991745b69e6c..d5a5031c48de6a 100644 --- a/libc/test/src/stdlib/strtof_test.cpp +++ b/libc/test/src/stdlib/strtof_test.cpp @@ -10,7 +10,7 @@ #include "src/errno/libc_errno.h" #include "src/stdlib/strtof.h" -#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/FPTest.h" #include "test/UnitTest/RoundingModeUtils.h" #include "test/UnitTest/Test.h"