This patch converts the TEST_f_L tests in libm-test.inc from code to
data. Tested x86_64 and x86.
2013-05-15 Joseph Myers <joseph@codesourcery.com>
* math/libm-test.inc (struct test_f_L_data): New type.
(RUN_TEST_LOOP_f_L): New macro.
(llrint_test_data): New variable.
(llrint_test): Run tests with RUN_TEST_LOOP_f_L.
(llrint_tonearest_test_data): New variable.
(llrint_test_tonearest): Run tests with RUN_TEST_LOOP_f_L.
(llrint_towardzero_test_data): New variable.
(llrint_test_towardzero): Run tests with RUN_TEST_LOOP_f_L.
(llrint_downward_test_data): New variable.
(llrint_test_downward): Run tests with RUN_TEST_LOOP_f_L.
(llrint_upward_test_data): New variable.
(llrint_test_upward): Run tests with RUN_TEST_LOOP_f_L.
(llround_test_data): New variable.
(llround_test): Run tests with RUN_TEST_LOOP_f_L.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 0843482..10378de 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -1009,6 +1009,14 @@ struct test_f_l_data
long int max_ulp;
int exceptions;
};
+struct test_f_L_data
+{
+ const char *test_name;
+ FLOAT arg;
+ long long int expected;
+ long long int max_ulp;
+ int exceptions;
+};
/* Set the rounding mode, or restore the saved value. */
#define IF_ROUND_INIT_ /* Empty. */
@@ -1281,6 +1289,13 @@ struct test_f_l_data
MAX_ULP, EXCEPTIONS) \
check_longlong (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED, \
MAX_ULP, EXCEPTIONS)
+#define RUN_TEST_LOOP_f_L(FUNC_NAME, ARRAY, ROUNDING_MODE) \
+ IF_ROUND_INIT_ ## ROUNDING_MODE \
+ for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
+ RUN_TEST_f_L ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg, \
+ (ARRAY)[i].expected, (ARRAY)[i].max_ulp, \
+ (ARRAY)[i].exceptions); \
+ ROUND_RESTORE_ ## ROUNDING_MODE
#define RUN_TEST_sincos(ARG, TEST_NAME_SIN, SIN_RES_VAR, EXPECTED_SIN, \
MAX_ULP_SIN, TEST_NAME_COS, COS_RES_VAR, \
EXPECTED_COS, MAX_ULP_COS, EXCEPTIONS) \
@@ -10546,682 +10561,674 @@ lrint_test_upward (void)
}
+static const struct test_f_L_data llrint_test_data[] =
+ {
+ START_DATA (llrint),
+ /* XXX this test is incomplete. We need to have a way to specifiy
+ the rounding method and test the critical cases. So far, only
+ unproblematic numbers are tested. */