Skip to content

Commit

Permalink
test: add missing tests, return NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjjoshi committed Jul 29, 2024
1 parent dc626ba commit 3c7856e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/powm1/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit 3c7856e

Please sign in to comment.