diff --git a/lib/node_modules/@stdlib/math/base/special/acotf/test/test.js b/lib/node_modules/@stdlib/math/base/special/acotf/test/test.js index 9d2ae37085b1..a48c0dc1c176 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acotf/test/test.js @@ -26,9 +26,8 @@ var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); -var EPS = require( '@stdlib/constants/float32/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var acotf = require( './../lib' ); @@ -54,8 +53,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the inverse cotangent for medium positive values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -66,21 +63,13 @@ tape( 'the function computes the inverse cotangent for medium positive values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.9 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for medium negative values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -91,21 +80,13 @@ tape( 'the function computes the inverse cotangent for medium negative values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.9 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for large positive values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -116,21 +97,13 @@ tape( 'the function computes the inverse cotangent for large positive values', f for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for large negative values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -141,21 +114,13 @@ tape( 'the function computes the inverse cotangent for large negative values', f for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for larger positive values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -166,21 +131,13 @@ tape( 'the function computes the inverse cotangent for larger positive values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for larger negative values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -191,21 +148,13 @@ tape( 'the function computes the inverse cotangent for larger negative values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for huge positive values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -216,21 +165,13 @@ tape( 'the function computes the inverse cotangent for huge positive values', fu for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for huge negative values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -241,13 +182,7 @@ tape( 'the function computes the inverse cotangent for huge negative values', fu for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/acotf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acotf/test/test.native.js index 7fc9651cd60a..478a7742d230 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acotf/test/test.native.js @@ -27,9 +27,8 @@ var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); -var EPS = require( '@stdlib/constants/float32/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -63,8 +62,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the inverse cotangent for medium positive values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -75,21 +72,13 @@ tape( 'the function computes the inverse cotangent for medium positive values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.9 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for medium negative values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -100,21 +89,13 @@ tape( 'the function computes the inverse cotangent for medium negative values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.9 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 3 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for large positive values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -125,21 +106,13 @@ tape( 'the function computes the inverse cotangent for large positive values', o for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for large negative values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -150,21 +123,13 @@ tape( 'the function computes the inverse cotangent for large negative values', o for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for larger positive values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -175,21 +140,13 @@ tape( 'the function computes the inverse cotangent for larger positive values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for larger negative values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -200,21 +157,13 @@ tape( 'the function computes the inverse cotangent for larger negative values', for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for huge positive values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -225,21 +174,13 @@ tape( 'the function computes the inverse cotangent for huge positive values', op for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the inverse cotangent for huge negative values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -250,13 +191,7 @@ tape( 'the function computes the inverse cotangent for huge negative values', op for ( i = 0; i < x.length; i++ ) { y = acotf( x[ i ] ); e = float64ToFloat32( expected[ i ] ); - if ( y === e ) { - t.strictEqual( y, e, 'x: '+x[ i ]+'. E: '+e+'.' ); - } else { - delta = abs( y - e ); - tol = 1.2 * EPS * abs( e ); - t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' ); } t.end(); });