diff --git a/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.assign.js index 82eca30e4675..e2e882f68596 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.assign.js +++ b/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.assign.js @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var Float64Array = require( '@stdlib/array/float64' ); var sincosd = require( './../lib/assign.js' ); @@ -50,9 +49,7 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var z; @@ -66,29 +63,15 @@ tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', func for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -102,29 +85,15 @@ tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', func for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 0 < x < 256*180.0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -138,29 +107,15 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*180.0)', funct for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -2**60 (180.0/2) < x < -2**20 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -174,29 +129,15 @@ tape( 'the function computes the sine and cosine (for -2**60 (180.0/2) < x < -2* for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 2**20 (180.0/2) < x < 2**60 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -210,29 +151,15 @@ tape( 'the function computes the sine and cosine (for 2**20 (180.0/2) < x < 2**6 for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x <= -2**60 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -246,29 +173,15 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (180.0/2))', f for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x >= 2**60 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -282,20 +195,8 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (180.0/2))', fu for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.main.js index b7c34d0e1aa5..c21da36d77bb 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.main.js +++ b/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.main.js @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var sincosd = require( './../lib/main.js' ); @@ -49,9 +48,7 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -62,29 +59,15 @@ tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', func for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 0 < x < 256*180.0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -95,29 +78,15 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*180.0)', funct for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -2**60 (180.0/2) < x < -2**20 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -128,29 +97,15 @@ tape( 'the function computes the sine and cosine (for -2**60 (180.0/2) < x < -2* for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 2**20 (180.0/2) < x < 2**60 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -161,29 +116,15 @@ tape( 'the function computes the sine and cosine (for 2**20 (180.0/2) < x < 2**6 for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x <= -2**60 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -194,29 +135,15 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (180.0/2))', f for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x >= 2**60 (180.0/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -227,20 +154,8 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (180.0/2))', fu for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.native.js index efe031ac247d..411babf4d8ca 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sincosd/test/test.native.js @@ -22,11 +22,10 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -58,9 +57,7 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -71,29 +68,15 @@ tape( 'the function computes the sine and cosine (for -256*180.0 < x < 0)', opts for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 0 < x < 256*180.0)', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -104,29 +87,15 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*180.0)', opts, for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = 1.01 * EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -2**60 (180.0/2) < x < -2**20 (180.0/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -137,29 +106,15 @@ tape( 'the function computes the sine and cosine (for -2**60 (180.0/2) < x < -2* for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 2**20 (180.0/2) < x < 2**60 (180.0/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -170,29 +125,15 @@ tape( 'the function computes the sine and cosine (for 2**20 (180.0/2) < x < 2**6 for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x <= -2**60 (180.0/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -203,29 +144,15 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (180.0/2))', o for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x >= 2**60 (180.0/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -236,20 +163,8 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (180.0/2))', op for ( i = 0; i < x.length; i++ ) { y = sincosd( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); });