From 3c7856efaee7d3b4cbe72ef1ff4808f765f0db5e Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 29 Jul 2024 09:36:57 +0530 Subject: [PATCH] test: add missing tests, return NaN --- .../@stdlib/math/base/special/powm1/lib/main.js | 2 +- .../@stdlib/math/base/special/powm1/test/test.js | 6 ++++++ .../@stdlib/math/base/special/powm1/test/test.native.js | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/powm1/lib/main.js b/lib/node_modules/@stdlib/math/base/special/powm1/lib/main.js index 370c03a8b88..36ee0f1f48a 100644 --- a/lib/node_modules/@stdlib/math/base/special/powm1/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/powm1/lib/main.js @@ -121,7 +121,7 @@ function powm1( b, x ) { } result = pow( b, x ) - 1.0; if ( isinfinite( result ) || isnan( result ) ) { - return 0.0 / 0.0; // NaN + return NaN; } return result; } diff --git a/lib/node_modules/@stdlib/math/base/special/powm1/test/test.js b/lib/node_modules/@stdlib/math/base/special/powm1/test/test.js index 011a978941b..ff2febeb23b 100644 --- a/lib/node_modules/@stdlib/math/base/special/powm1/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/powm1/test/test.js @@ -141,3 +141,9 @@ tape( 'the function returns `NaN` if provided a `NaN` for the base', function te t.equal( isnan( y ), true, 'returns NaN' ); t.end(); }); + +tape( 'the function returns `NaN` if provided a `1e308` for the base and `2.0` for the exponent', function test( t ) { + var y = powm1( 1e308, 2.0 ); + t.equal( isnan( y ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/powm1/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/powm1/test/test.native.js index 9e13e924aa9..f360ec47401 100644 --- a/lib/node_modules/@stdlib/math/base/special/powm1/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/powm1/test/test.native.js @@ -150,3 +150,9 @@ tape( 'the function returns `NaN` if provided a `NaN` for the base', opts, funct t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); + +tape( 'the function returns `NaN` if provided a `1e308` for the base and `2.0` for the exponent', opts, function test( t ) { + var y = powm1( 1e308, 2.0 ); + t.equal( isnan( y ), true, 'returns expected value' ); + t.end(); +});