diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-sincos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-sincos/test/test.native.js index 00489a74b470..7990f4d88387 100644 --- a/lib/node_modules/@stdlib/math/base/special/kernel-sincos/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/kernel-sincos/test/test.native.js @@ -23,8 +23,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var rempio2 = require( '@stdlib/math/base/special/rempio2' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -63,9 +62,7 @@ tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) tape( 'the function evaluates the sine and cosine for input values on the interval `[-pi/4, pi/4]`', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -76,15 +73,9 @@ tape( 'the function evaluates the sine and cosine for input values on the interv for ( i = 0; i < x.length; i++ ) { y = kernelSincos( x[i], 0.0 ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'returns expected value' ); - } else { - delta = abs( y[0] - sine[i] ); - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[0], sine[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( y[1], cosine[ i ], 'returns expected value' ); } t.end(); @@ -92,9 +83,7 @@ tape( 'the function evaluates the sine and cosine for input values on the interv tape( 'the function can be used to compute the sine and cosine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (positive)', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var out; var x; var y; @@ -110,39 +99,21 @@ tape( 'the function can be used to compute the sine and cosine for input values switch ( n & 3 ) { case 0: out = kernelSincos( y[ 0 ], y[ 1 ] ); - if ( out[0] === sine[ i ] ) { - t.strictEqual( out[0], sine[ i ], 'returns expected value' ); - } else { - delta = abs( out[0] - sine[i] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( out[1], cosine[ i ], 'returns expected value' ); break; case 2: out = kernelSincos( y[ 0 ], y[ 1 ] ); out[ 0 ] = -out[ 0 ]; out[ 1 ] = -out[ 1 ]; - if ( out[0] === sine[ i ] ) { - t.strictEqual( out[0], sine[ i ], 'returns expected value' ); - } else { - delta = abs( out[0] - sine[i] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( out[1] === cosine[ i ] ) { - t.strictEqual( out[1], cosine[ i ], 'returns expected value' ); - } else { - delta = abs( out[1] - cosine[i] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out[1], cosine[ i ], 1 ), true, 'returns expected value' ); break; default: break; @@ -153,9 +124,7 @@ tape( 'the function can be used to compute the sine and cosine for input values tape( 'the function can be used to compute the sine and cosine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (negative)', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var out; var x; var y; @@ -171,39 +140,21 @@ tape( 'the function can be used to compute the sine and cosine for input values switch ( n & 3 ) { case 0: out = kernelSincos( y[ 0 ], y[ 1 ] ); - if ( out[0] === sine[ i ] ) { - t.strictEqual( out[0], sine[ i ], 'returns expected value' ); - } else { - delta = abs( out[0] - sine[i] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( out[1], cosine[ i ], 'returns expected value' ); break; case 2: out = kernelSincos( y[ 0 ], y[ 1 ] ); out[ 0 ] = -out[ 0 ]; out[ 1 ] = -out[ 1 ]; - if ( out[0] === sine[ i ] ) { - t.strictEqual( out[0], sine[ i ], 'returns expected value' ); - } else { - delta = abs( out[0] - sine[i] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( out[1] === cosine[ i ] ) { - t.strictEqual( out[1], cosine[ i ], 'returns expected value' ); - } else { - delta = abs( out[1] - cosine[i] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out[1], cosine[ i ], 1 ), true, 'returns expected value' ); break; default: break;