diff --git a/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.js b/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.js index 0e16347cac74..c7551f6071e2 100644 --- a/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.js @@ -26,8 +26,7 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var cbrt = require( './../lib' ); @@ -59,8 +58,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function evaluates the cubic root of `x` on the interval `[-50,-500]', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -69,21 +66,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-50,-500]' x = veryLargeNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[50,500]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -92,21 +81,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[50,500]`', x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-50]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -115,21 +96,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-50]`' x = largeNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[20,50]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -138,21 +111,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[20,50]`', x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-3]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -161,21 +126,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-3]`', x = mediumNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[3,20]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -184,21 +141,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[3,20]`', f x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-3,-0.8]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -207,21 +156,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-3,-0.8]`' x = smallNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[0.8,3]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -230,21 +171,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[0.8,3]`', x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates cubic root of `x` on the interval `[-0.8,0.8]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -253,21 +186,13 @@ tape( 'the function evaluates cubic root of `x` on the interval `[-0.8,0.8]`', f x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-1e-300,-1e-308]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -276,21 +201,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-1e-300,-1 x = tinyNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[1e-300,1e-308]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -299,21 +216,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[1e-300,1e- x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of subnormal `x`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -322,21 +231,13 @@ tape( 'the function evaluates the cubic root of subnormal `x`', function test( t x = subnormal.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` (huge negative)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -346,21 +247,13 @@ tape( 'the function evaluates the cubic root of `x` (huge negative)', function t for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` (huge positive)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -370,13 +263,7 @@ tape( 'the function evaluates the cubic root of `x` (huge positive)', function t for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });