From 51af03328755c9095e94d20858a8d10acfe412ae Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 9 Feb 2021 23:37:08 +0100 Subject: [PATCH] Add test case for 93fc67896550 (incorrect powf(3) result) This adds the test case to contrib/netbsd-tests/lib/libm/t_pow.c, as it is currently the only place testing pow(3) and friends. MFC after: 1 week --- contrib/netbsd-tests/lib/libm/t_pow.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contrib/netbsd-tests/lib/libm/t_pow.c b/contrib/netbsd-tests/lib/libm/t_pow.c index 7afee9f6dffa..09e72be7311b 100644 --- a/contrib/netbsd-tests/lib/libm/t_pow.c +++ b/contrib/netbsd-tests/lib/libm/t_pow.c @@ -637,6 +637,27 @@ ATF_TC_BODY(powf_zero_y, tc) } } +ATF_TC(powf_near_one_x_huge_y); +ATF_TC_HEAD(powf_near_one_x_huge_y, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test powf(->1, huge) != inf"); +} + +ATF_TC_BODY(powf_near_one_x_huge_y, tc) +{ + const float x = 0x1.ffffeep-1f; /* 9.999995e-01f */ + const float y = -0x1.000002p+27f; /* -1.342177e+08f */ + const float e = 0x1.d53532p+103f; /* 1.858724e+31f */ + const float ulp = __FLT_EPSILON__; + float z; + + z = powf(x, y); + + ATF_CHECK(isinf(z) == 0); + ATF_CHECK(fabsf(z - e) <= 2 * ulp); +} + + ATF_TP_ADD_TCS(tp) { @@ -661,6 +682,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, powf_one_pos_x); ATF_TP_ADD_TC(tp, powf_zero_x); ATF_TP_ADD_TC(tp, powf_zero_y); + ATF_TP_ADD_TC(tp, powf_near_one_x_huge_y); return atf_no_error(); }