From 91ed71753d9a629c94ccdeb56cb79a5d952980e2 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Tue, 1 Dec 2026 16:44:28 +0100 Subject: [PATCH] Tests: tolerate rounding differences in Math.tanh() On Alpine Linux/i686, Math.tanh(0.5) differs from the reference expression (Math.E - 1)/(Math.E + 1) by one ULP (about 5.55e-17). The exact comparison fails with both SSE and x87 builds. Allow an absolute difference of Number.EPSILON, as in the tests for Math.atanh() and Math.acosh(). --- src/test/njs_unit_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 7f3721fe..464adedb 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -19173,8 +19173,9 @@ static njs_unit_test_t njs_test[] = { njs_str("Math.tanh(-Infinity)"), njs_str("-1") }, - { njs_str("Math.tanh(0.5) - (Math.E - 1)/(Math.E + 1)"), - njs_str("0") }, + { njs_str("Math.abs(Math.tanh(0.5) - (Math.E - 1)/(Math.E + 1))" + " <= Number.EPSILON"), + njs_str("true") }, { njs_str("Math.trunc(3.9)"), njs_str("3") }, -- 2.47.3