Clean up exhaustive tests. Let check functions return number of failures instead of passed/failed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| libc/test/src/math/exhaustive/exhaustive_test.h | ||
|---|---|---|
| 39 | Can this be more specific like: template <typename FloatType>
using FuncType = FloatType(FloatType);
template <typename FloatType, __llvm_libc::testing::mpfr::Operation Op, FuncType<FloatType> Func>
struct LlvmLibcExhaustiveMathTest ... {
...
static constexpr FuncType<FloatType> *FUNC = Func;
uint64_t check(...) {
bool correct = TEST_MPFR_MATCH_ROUNDING_SILENTLY(Op, x, FUNC(x), 0.5, rounding);
}
...
}For erff, you can do: using LlvmLibcErffExhaustiveTest : publicLlvmLibcExhaustiveTest<float, mpfr::Operation::ErfOp, __llvm_libc::erff>; | |
| 45 | Why is this virtual? | |
| 56 | Do we tolerate errors? | |
| libc/test/src/math/exhaustive/exhaustive_test.h | ||
|---|---|---|
| 39 | I've separated them into Checker class to provide the check method, and the canonical UnaryOpChecker::check method. Other examples of Checker are in hypotf_test and sincosf_test. Then the LlvmLibcUnaryOpExhaustiveMathTest will take 3 template parameters as you suggested. | |
| 45 | Originally, it is virtual so that different tests such as hypotf or sincosf can override the check method. I refactored the classes so that the check method does not need to be virtual. | |
| 56 | We do not tolerate errors, but providing the number of failed inputs is very useful when choosing the polynomial approximation. | |
Can this be more specific like:
template <typename FloatType> using FuncType = FloatType(FloatType); template <typename FloatType, __llvm_libc::testing::mpfr::Operation Op, FuncType<FloatType> Func> struct LlvmLibcExhaustiveMathTest ... { ... static constexpr FuncType<FloatType> *FUNC = Func; uint64_t check(...) { bool correct = TEST_MPFR_MATCH_ROUNDING_SILENTLY(Op, x, FUNC(x), 0.5, rounding); } ... }For erff, you can do: