diff --git a/lib/node_modules/@stdlib/math/base/special/erfc/test/test.js b/lib/node_modules/@stdlib/math/base/special/erfc/test/test.js index ceb8d19b0c3a..d51338008876 100644 --- a/lib/node_modules/@stdlib/math/base/special/erfc/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/erfc/test/test.js @@ -24,8 +24,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PINF = require( '@stdlib/constants/float64/pinf' ); -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 erfc = require( './../lib' ); @@ -55,8 +54,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function evaluates the complementary error function for `x` on the interval `[-5,-100]', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -65,21 +62,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largerNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 complementary error function for `x` on the interval `[5,100]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -88,21 +77,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largerPositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 complementary error function for `x` on the interval `[-2.5,-28]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -111,21 +92,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largeNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 complementary error function for `x` on the interval `[2.5,28]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -134,21 +107,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 complementary error function for `x` on the interval `[-1,-3]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -157,21 +122,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = mediumNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 complementary error function for `x` on the interval `[1,3]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -180,21 +137,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 complementary error function for `x` on the interval `[-0.8,-1]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -203,13 +152,7 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = smallNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/erfc/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/erfc/test/test.native.js index 549256b345b5..28d1fd039cde 100644 --- a/lib/node_modules/@stdlib/math/base/special/erfc/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/erfc/test/test.native.js @@ -26,8 +26,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var tryRequire = require( '@stdlib/utils/try-require' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); // FIXTURES // @@ -64,8 +63,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function evaluates the complementary error function for `x` on the interval `[-5,-100]', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -74,21 +71,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largerNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[5,100]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -97,21 +86,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largerPositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[-2.5,-28]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -120,21 +101,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largeNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[2.5,28]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -143,21 +116,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[-1,-3]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -166,21 +131,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = mediumNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[1,3]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -189,21 +146,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the complementary error function for `x` on the interval `[-0.8,-1]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -212,21 +161,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = smallNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[0.8,1]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -235,21 +176,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the complementary error function for `x` on the interval `[-0.8,0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -258,21 +191,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 2.0 * 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 complementary error function for `x` on the interval `[-1e-300,-1e-308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -281,21 +206,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = tinyNegative.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 1.0 * 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 complementary error function for `x` on the interval `[1e-300,1e-308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -304,21 +221,13 @@ tape( 'the function evaluates the complementary error function for `x` on the in x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 1.0 * 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 complementary error function for subnormal `x`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -327,13 +236,7 @@ tape( 'the function evaluates the complementary error function for subnormal `x` x = subnormal.x; for ( i = 0; i < x.length; i++ ) { y = erfc( 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 = 1.0 * 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(); });