Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 70 additions & 49 deletions lib/node_modules/@stdlib/math/base/special/atan2/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,118 +48,139 @@ tape( 'main export is a function', function test( t ) {
});

tape( 'the function has two parameters: a numerator and a denominator value', function test( t ) {
t.equal( atan2.length, 2.0, 'arity is 2' );
t.equal( atan2.length, 2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided `NaN` as either of the arguments', function test( t ) {
t.equal( isnan( atan2( 2.0, NaN ) ), true, 'returns NaN' );
t.equal( isnan( atan2( NaN, 3.0 ) ), true, 'returns NaN' );
t.equal( isnan( atan2( 2.0, NaN ) ), true, 'returns expected value' );
t.equal( isnan( atan2( NaN, 3.0 ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `+0` if provided `y = +0.0` and `x >= 0`', function test( t ) {
t.equal( isPositiveZero( atan2( +0.0, 0.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 2.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 4.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 5.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 10.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 0.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 2.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 4.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 5.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 10.0 ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `-0` if provided `y = -0.0` and `x >= 0`', function test( t ) {
t.equal( isNegativeZero( atan2( -0.0, 0.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 2.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 4.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 5.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 10.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 0.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 2.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 4.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 5.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 10.0 ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `PI` if provided `y = +0.0` and `x <= -0.0`', function test( t ) {
t.equal( atan2( +0.0, -0.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -2.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -4.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -5.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -10.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -0.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -2.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -4.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -5.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -10.0 ), +PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI` if provided `y = -0.0` and `x <= -0.0`', function test( t ) {
t.equal( atan2( -0.0, -0.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -2.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -4.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -5.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -10.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -0.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -2.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -4.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -5.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -10.0 ), -PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `+PI/4` if provided `x = y = +infinity`', function test( t ) {
t.equal( atan2( PINF, PINF ), +PI/4.0, 'returns +PI/4' );
t.equal( atan2( PINF, PINF ), +PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/4` if provided `x = -y = +infinity`', function test( t ) {
t.equal( atan2( NINF, PINF ), -PI/4.0, 'returns -PI/4' );
t.equal( atan2( NINF, PINF ), -PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `*3*PI/4` if provided `-x = y = +infinity`', function test( t ) {
t.equal( atan2( PINF, NINF ), +3.0*PI/4.0, 'returns +3*PI/4' );
t.equal( atan2( PINF, NINF ), +3.0*PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-3*PI/4` if provided `x = y = -infinity`', function test( t ) {
t.equal( atan2( NINF, NINF ), -3.0*PI/4.0, 'returns -3*PI/4' );
t.equal( atan2( NINF, NINF ), -3.0*PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `0.0` when `x = +infinity`', function test( t ) {
t.equal( atan2( -2.0, PINF ), 0.0, 'returns 0.0' );
t.equal( atan2( 0.0, PINF ), 0.0, 'returns 0.0' );
t.equal( atan2( 2.0, PINF ), 0.0, 'returns 0.0' );
tape( 'the function returns `0.0` when `y > 0` and `x = +infinity`', function test( t ) {
t.equal( isPositiveZero( atan2( 1.0, PINF ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( 2.0, PINF ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( 3.0, PINF ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `-0.0` when `y < 0` and `x = +infinity`', function test( t ) {
t.equal( isNegativeZero( atan2( -1.0, PINF ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -2.0, PINF ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -3.0, PINF ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `+PI` when `y > 0` and `x = -infinity`', function test( t ) {
t.equal( atan2( 1.0, NINF ), PI, 'returns PI' );
t.equal( atan2( 2.0, NINF ), PI, 'returns PI' );
t.equal( atan2( 3.0, NINF ), PI, 'returns PI' );
t.equal( atan2( 1.0, NINF ), PI, 'returns expected value' );
t.equal( atan2( 2.0, NINF ), PI, 'returns expected value' );
t.equal( atan2( 3.0, NINF ), PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI` when `y < 0` and `x = -infinity`', function test( t ) {
t.equal( atan2( -1.0, NINF ), -PI, 'returns -PI' );
t.equal( atan2( -2.0, NINF ), -PI, 'returns -PI' );
t.equal( atan2( -3.0, NINF ), -PI, 'returns -PI' );
t.equal( atan2( -1.0, NINF ), -PI, 'returns expected value' );
t.equal( atan2( -2.0, NINF ), -PI, 'returns expected value' );
t.equal( atan2( -3.0, NINF ), -PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `+PI/2` when `y = +infinity`', function test( t ) {
t.equal( atan2( PINF, -1.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( PINF, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( PINF, 2.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( PINF, -1.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( PINF, 0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( PINF, 2.0 ), PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/2` when `y = -infinity`', function test( t ) {
t.equal( atan2( NINF, -1.0 ), -PI/2.0, 'returns -PI/2' );
t.equal( atan2( NINF, 0.0 ), -PI/2.0, 'returns -PI/2' );
t.equal( atan2( NINF, 2.0 ), -PI/2.0, 'returns -PI/2' );
t.equal( atan2( NINF, -1.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( NINF, 0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( NINF, 2.0 ), -PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `PI/2` if provided a positive `y` and `x=0`', function test( t ) {
t.equal( atan2( 2.0, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( 1.0, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( 0.5, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( 2.0, 0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 1.0, 0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 0.5, 0.0 ), PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `PI/2` if provided a positive `y` and `x=-0`', function test( t ) {
t.equal( atan2( 2.0, -0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 1.0, -0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 0.5, -0.0 ), PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/2` if provided a negative `y` and `x=0`', function test( t ) {
t.equal( atan2( -2.0, 0.0 ), -PI/2.0, 'returns PI/2' );
t.equal( atan2( -1.0, 0.0 ), -PI/2.0, 'returns PI/2' );
t.equal( atan2( -0.5, 0.0 ), -PI/2.0, 'returns PI/2' );
t.equal( atan2( -2.0, 0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -1.0, 0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -0.5, 0.0 ), -PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/2` if provided a negative `y` and `x=-0`', function test( t ) {
t.equal( atan2( -2.0, -0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -1.0, -0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -0.5, -0.0 ), -PI/2.0, 'returns expected value' );
t.end();
});

Expand Down
119 changes: 70 additions & 49 deletions lib/node_modules/@stdlib/math/base/special/atan2/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,118 +57,139 @@ tape( 'main export is a function', opts, function test( t ) {
});

tape( 'the function has two parameters: a numerator and a denominator value', opts, function test( t ) {
t.equal( atan2.length, 2.0, 'arity is 2' );
t.equal( atan2.length, 2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided `NaN` as either of the arguments', opts, function test( t ) {
t.equal( isnan( atan2( 2.0, NaN ) ), true, 'returns NaN' );
t.equal( isnan( atan2( NaN, 3.0 ) ), true, 'returns NaN' );
t.equal( isnan( atan2( 2.0, NaN ) ), true, 'returns expected value' );
t.equal( isnan( atan2( NaN, 3.0 ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `+0` if provided `y = +0.0` and `x >= 0`', opts, function test( t ) {
t.equal( isPositiveZero( atan2( +0.0, 0.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 2.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 4.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 5.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 10.0 ) ), true, 'returns +0' );
t.equal( isPositiveZero( atan2( +0.0, 0.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 2.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 4.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 5.0 ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( +0.0, 10.0 ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `-0` if provided `y = -0.0` and `x >= 0`', opts, function test( t ) {
t.equal( isNegativeZero( atan2( -0.0, 0.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 2.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 4.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 5.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 10.0 ) ), true, 'returns -0' );
t.equal( isNegativeZero( atan2( -0.0, 0.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 2.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 4.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 5.0 ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -0.0, 10.0 ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `PI` if provided `y = +0.0` and `x <= -0.0`', opts, function test( t ) {
t.equal( atan2( +0.0, -0.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -2.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -4.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -5.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -10.0 ), +PI, 'returns +PI' );
t.equal( atan2( +0.0, -0.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -2.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -4.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -5.0 ), +PI, 'returns expected value' );
t.equal( atan2( +0.0, -10.0 ), +PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI` if provided `y = -0.0` and `x <= -0.0`', opts, function test( t ) {
t.equal( atan2( -0.0, -0.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -2.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -4.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -5.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -10.0 ), -PI, 'returns -PI' );
t.equal( atan2( -0.0, -0.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -2.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -4.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -5.0 ), -PI, 'returns expected value' );
t.equal( atan2( -0.0, -10.0 ), -PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `+PI/4` if provided `x = y = +infinity`', opts, function test( t ) {
t.equal( atan2( PINF, PINF ), +PI/4.0, 'returns +PI/4' );
t.equal( atan2( PINF, PINF ), +PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/4` if provided `x = -y = +infinity`', opts, function test( t ) {
t.equal( atan2( NINF, PINF ), -PI/4.0, 'returns -PI/4' );
t.equal( atan2( NINF, PINF ), -PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `*3*PI/4` if provided `-x = y = +infinity`', opts, function test( t ) {
t.equal( atan2( PINF, NINF ), +3.0*PI/4.0, 'returns +3*PI/4' );
t.equal( atan2( PINF, NINF ), +3.0*PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-3*PI/4` if provided `x = y = -infinity`', opts, function test( t ) {
t.equal( atan2( NINF, NINF ), -3.0*PI/4.0, 'returns -3*PI/4' );
t.equal( atan2( NINF, NINF ), -3.0*PI/4.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `0.0` when `x = +infinity`', opts, function test( t ) {
t.equal( atan2( -2.0, PINF ), 0.0, 'returns 0.0' );
t.equal( atan2( 0.0, PINF ), 0.0, 'returns 0.0' );
t.equal( atan2( 2.0, PINF ), 0.0, 'returns 0.0' );
tape( 'the function returns `0.0` when `y > 0` and `x = +infinity`', opts, function test( t ) {
t.equal( isPositiveZero( atan2( 1.0, PINF ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( 2.0, PINF ) ), true, 'returns expected value' );
t.equal( isPositiveZero( atan2( 3.0, PINF ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `-0.0` when `y < 0` and `x = +infinity`', opts, function test( t ) {
t.equal( isNegativeZero( atan2( -1.0, PINF ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -2.0, PINF ) ), true, 'returns expected value' );
t.equal( isNegativeZero( atan2( -3.0, PINF ) ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `+PI` when `y > 0` and `x = -infinity`', opts, function test( t ) {
t.equal( atan2( 1.0, NINF ), PI, 'returns PI' );
t.equal( atan2( 2.0, NINF ), PI, 'returns PI' );
t.equal( atan2( 3.0, NINF ), PI, 'returns PI' );
t.equal( atan2( 1.0, NINF ), PI, 'returns expected value' );
t.equal( atan2( 2.0, NINF ), PI, 'returns expected value' );
t.equal( atan2( 3.0, NINF ), PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI` when `y < 0` and `x = -infinity`', opts, function test( t ) {
t.equal( atan2( -1.0, NINF ), -PI, 'returns -PI' );
t.equal( atan2( -2.0, NINF ), -PI, 'returns -PI' );
t.equal( atan2( -3.0, NINF ), -PI, 'returns -PI' );
t.equal( atan2( -1.0, NINF ), -PI, 'returns expected value' );
t.equal( atan2( -2.0, NINF ), -PI, 'returns expected value' );
t.equal( atan2( -3.0, NINF ), -PI, 'returns expected value' );
t.end();
});

tape( 'the function returns `+PI/2` when `y = +infinity`', opts, function test( t ) {
t.equal( atan2( PINF, -1.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( PINF, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( PINF, 2.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( PINF, -1.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( PINF, 0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( PINF, 2.0 ), PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/2` when `y = -infinity`', opts, function test( t ) {
t.equal( atan2( NINF, -1.0 ), -PI/2.0, 'returns -PI/2' );
t.equal( atan2( NINF, 0.0 ), -PI/2.0, 'returns -PI/2' );
t.equal( atan2( NINF, 2.0 ), -PI/2.0, 'returns -PI/2' );
t.equal( atan2( NINF, -1.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( NINF, 0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( NINF, 2.0 ), -PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `PI/2` if provided a positive `y` and `x=0`', opts, function test( t ) {
t.equal( atan2( 2.0, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( 1.0, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( 0.5, 0.0 ), PI/2.0, 'returns PI/2' );
t.equal( atan2( 2.0, 0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 1.0, 0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 0.5, 0.0 ), PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `PI/2` if provided a positive `y` and `x=-0`', opts, function test( t ) {
t.equal( atan2( 2.0, -0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 1.0, -0.0 ), PI/2.0, 'returns expected value' );
t.equal( atan2( 0.5, -0.0 ), PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/2` if provided a negative `y` and `x=0`', opts, function test( t ) {
t.equal( atan2( -2.0, 0.0 ), -PI/2.0, 'returns PI/2' );
t.equal( atan2( -1.0, 0.0 ), -PI/2.0, 'returns PI/2' );
t.equal( atan2( -0.5, 0.0 ), -PI/2.0, 'returns PI/2' );
t.equal( atan2( -2.0, 0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -1.0, 0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -0.5, 0.0 ), -PI/2.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `-PI/2` if provided a negative `y` and `x=-0`', opts, function test( t ) {
t.equal( atan2( -2.0, -0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -1.0, -0.0 ), -PI/2.0, 'returns expected value' );
t.equal( atan2( -0.5, -0.0 ), -PI/2.0, 'returns expected value' );
t.end();
});

Expand Down