[libc-commits] [libc] [libc][NFC] Shorten type names in tests (PR #75358)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Wed Dec 13 09:07:03 PST 2023
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/75358
None
>From cb96028d2d921229011621e835a3095c8e4c54b3 Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Wed, 13 Dec 2023 17:06:41 +0000
Subject: [PATCH] [libc][NFC] Shorten type names in tests
---
libc/test/src/math/FDimTest.h | 10 +++++-----
libc/test/src/math/FmaTest.h | 10 +++++-----
libc/test/src/math/ILogbTest.h | 15 ++++++---------
libc/test/src/math/LdExpTest.h | 10 +++++-----
libc/test/src/math/RemQuoTest.h | 10 +++++-----
libc/test/src/math/smoke/FDimTest.h | 10 +++++-----
libc/test/src/math/smoke/FmaTest.h | 10 +++++-----
libc/test/src/math/smoke/ILogbTest.h | 15 ++++++---------
libc/test/src/math/smoke/LdExpTest.h | 10 +++++-----
libc/test/src/math/smoke/RemQuoTest.h | 10 +++++-----
10 files changed, 52 insertions(+), 58 deletions(-)
diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h
index 3118c3661013e7..3fb82ed8bca2ce 100644
--- a/libc/test/src/math/FDimTest.h
+++ b/libc/test/src/math/FDimTest.h
@@ -74,9 +74,9 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
private:
// constexpr does not work on FPBits yet, so we cannot have these constants as
// static.
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
+ const T nan = T(FPBits::build_quiet_nan(1));
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
};
diff --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h
index c2573d03792692..94412b7021df37 100644
--- a/libc/test/src/math/FmaTest.h
+++ b/libc/test/src/math/FmaTest.h
@@ -23,11 +23,11 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
using Func = T (*)(T, T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using UIntType = typename FPBits::UIntType;
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
+ const T nan = T(FPBits::build_quiet_nan(1));
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
UIntType get_random_bit_pattern() {
UIntType bits{0};
diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h
index e51a5d7a2544cd..9e12b4515c2852 100644
--- a/libc/test/src/math/ILogbTest.h
+++ b/libc/test/src/math/ILogbTest.h
@@ -24,15 +24,12 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
void test_special_numbers(typename ILogbFunc<T>::Func func) {
- EXPECT_EQ(FP_ILOGB0, func(T(LIBC_NAMESPACE::fputil::FPBits<T>::zero())));
- EXPECT_EQ(FP_ILOGB0,
- func(T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero())));
-
- EXPECT_EQ(FP_ILOGBNAN,
- func(T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1))));
-
- EXPECT_EQ(INT_MAX, func(T(LIBC_NAMESPACE::fputil::FPBits<T>::inf())));
- EXPECT_EQ(INT_MAX, func(T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf())));
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
+ EXPECT_EQ(FP_ILOGB0, func(T(FPBits::zero())));
+ EXPECT_EQ(FP_ILOGB0, func(T(FPBits::neg_zero())));
+ EXPECT_EQ(FP_ILOGBNAN, func(T(FPBits::build_quiet_nan(1))));
+ EXPECT_EQ(INT_MAX, func(T(FPBits::inf())));
+ EXPECT_EQ(INT_MAX, func(T(FPBits::neg_inf())));
}
template <typename T>
diff --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h
index a75c8ef31a2cf8..ce0896ec2f4c25 100644
--- a/libc/test/src/math/LdExpTest.h
+++ b/libc/test/src/math/LdExpTest.h
@@ -28,11 +28,11 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::Test {
// A normalized mantissa to be used with tests.
static constexpr UIntType MANTISSA = NormalFloat::ONE + 0x1234;
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T nan = T(FPBits::build_quiet_nan(1));
public:
typedef T (*LdExpFunc)(T, int);
diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
index 6da0756c3a1b3d..a345e8b72e78d0 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -23,11 +23,11 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using UIntType = typename FPBits::UIntType;
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T nan = T(FPBits::build_quiet_nan(1));
public:
typedef T (*RemQuoFunc)(T, T, int *);
diff --git a/libc/test/src/math/smoke/FDimTest.h b/libc/test/src/math/smoke/FDimTest.h
index 3118c3661013e7..3fb82ed8bca2ce 100644
--- a/libc/test/src/math/smoke/FDimTest.h
+++ b/libc/test/src/math/smoke/FDimTest.h
@@ -74,9 +74,9 @@ class FDimTestTemplate : public LIBC_NAMESPACE::testing::Test {
private:
// constexpr does not work on FPBits yet, so we cannot have these constants as
// static.
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
+ const T nan = T(FPBits::build_quiet_nan(1));
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
};
diff --git a/libc/test/src/math/smoke/FmaTest.h b/libc/test/src/math/smoke/FmaTest.h
index 3c1c120d77d450..1da9652bfee155 100644
--- a/libc/test/src/math/smoke/FmaTest.h
+++ b/libc/test/src/math/smoke/FmaTest.h
@@ -19,11 +19,11 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
using Func = T (*)(T, T, T);
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using UIntType = typename FPBits::UIntType;
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
+ const T nan = T(FPBits::build_quiet_nan(1));
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
public:
void test_special_numbers(Func func) {
diff --git a/libc/test/src/math/smoke/ILogbTest.h b/libc/test/src/math/smoke/ILogbTest.h
index e51a5d7a2544cd..9e12b4515c2852 100644
--- a/libc/test/src/math/smoke/ILogbTest.h
+++ b/libc/test/src/math/smoke/ILogbTest.h
@@ -24,15 +24,12 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::Test {
template <typename T>
void test_special_numbers(typename ILogbFunc<T>::Func func) {
- EXPECT_EQ(FP_ILOGB0, func(T(LIBC_NAMESPACE::fputil::FPBits<T>::zero())));
- EXPECT_EQ(FP_ILOGB0,
- func(T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero())));
-
- EXPECT_EQ(FP_ILOGBNAN,
- func(T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1))));
-
- EXPECT_EQ(INT_MAX, func(T(LIBC_NAMESPACE::fputil::FPBits<T>::inf())));
- EXPECT_EQ(INT_MAX, func(T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf())));
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
+ EXPECT_EQ(FP_ILOGB0, func(T(FPBits::zero())));
+ EXPECT_EQ(FP_ILOGB0, func(T(FPBits::neg_zero())));
+ EXPECT_EQ(FP_ILOGBNAN, func(T(FPBits::build_quiet_nan(1))));
+ EXPECT_EQ(INT_MAX, func(T(FPBits::inf())));
+ EXPECT_EQ(INT_MAX, func(T(FPBits::neg_inf())));
}
template <typename T>
diff --git a/libc/test/src/math/smoke/LdExpTest.h b/libc/test/src/math/smoke/LdExpTest.h
index a75c8ef31a2cf8..ce0896ec2f4c25 100644
--- a/libc/test/src/math/smoke/LdExpTest.h
+++ b/libc/test/src/math/smoke/LdExpTest.h
@@ -28,11 +28,11 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::Test {
// A normalized mantissa to be used with tests.
static constexpr UIntType MANTISSA = NormalFloat::ONE + 0x1234;
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T nan = T(FPBits::build_quiet_nan(1));
public:
typedef T (*LdExpFunc)(T, int);
diff --git a/libc/test/src/math/smoke/RemQuoTest.h b/libc/test/src/math/smoke/RemQuoTest.h
index 5a5d1437775023..514190b6b31caa 100644
--- a/libc/test/src/math/smoke/RemQuoTest.h
+++ b/libc/test/src/math/smoke/RemQuoTest.h
@@ -20,11 +20,11 @@ class RemQuoTestTemplate : public LIBC_NAMESPACE::testing::Test {
using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
using UIntType = typename FPBits::UIntType;
- const T zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::zero());
- const T neg_zero = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_zero());
- const T inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::inf());
- const T neg_inf = T(LIBC_NAMESPACE::fputil::FPBits<T>::neg_inf());
- const T nan = T(LIBC_NAMESPACE::fputil::FPBits<T>::build_quiet_nan(1));
+ const T zero = T(FPBits::zero());
+ const T neg_zero = T(FPBits::neg_zero());
+ const T inf = T(FPBits::inf());
+ const T neg_inf = T(FPBits::neg_inf());
+ const T nan = T(FPBits::build_quiet_nan(1));
public:
typedef T (*RemQuoFunc)(T, T, int *);
More information about the libc-commits
mailing list