From: Jakub Jirutka Date: Tue, 1 Dec 2026 15:44:28 +0000 (+0100) Subject: Tests: tolerate rounding differences in Math.tanh() X-Git-Url: https://git.kaiwu.me/web/ngx_http_fastcgi_module.html?a=commitdiff_plain;p=njs.git 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(). --- 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") },