From e8be3cee31c5ae431c2004d34bdc00579f3efd35 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Aug 2026 22:24:27 +0000 Subject: [PATCH] test: migrate `math/base/special/fast/asinh` to ULP-based assertions Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01D3zHCEMhwS9mRnbZ9MvaxJ --- .../math/base/special/fast/asinh/test/test.js | 92 ++----------------- .../special/fast/asinh/test/test.native.js | 92 ++----------------- 2 files changed, 20 insertions(+), 164 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.js b/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.js index c2b19d42885c..01217d6f230b 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.js @@ -21,13 +21,13 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var abs = require( '@stdlib/math/base/special/abs' ); var asinh = require( './../lib' ); @@ -61,8 +61,6 @@ tape( 'the function underflows if provided a number which is negligible compared tape( 'the function computes the hyperbolic arcsine on the interval `[-0.8,0.8]` (tests whether `asinh` behaves as an odd function)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -72,21 +70,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-0.8,0.8]` for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 50.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 79 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-1.0,-0.8]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -96,21 +86,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-1.0,-0.8] for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.5 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[0.8,1.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -120,21 +102,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[0.8,1.0]`' for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.5 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-3.0,-1.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -144,21 +118,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-3.0,-1.0] for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[1.0,3.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -168,21 +134,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[1.0,3.0]`' for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[3.0,28.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -192,21 +150,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[3.0,28.0]` for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-28.0,-3.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -216,21 +166,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-28.0,-3.0 for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[28.0,100.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -240,21 +182,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[28.0,100.0 for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-100.0,-28.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -264,13 +198,7 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-100.0,-28 for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.native.js index 5cf402a7663e..700b8a46c6e9 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/asinh/test/test.native.js @@ -22,13 +22,13 @@ 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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var abs = require( '@stdlib/math/base/special/abs' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -70,8 +70,6 @@ tape( 'the function underflows if provided a number which is negligible compared tape( 'the function computes the hyperbolic arcsine on the interval `[-0.8,0.8]` (tests whether `asinh` behaves as an odd function)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -81,21 +79,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-0.8,0.8]` for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 50.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 79 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-1.0,-0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -105,21 +95,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-1.0,-0.8] for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.5 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[0.8,1.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -129,21 +111,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[0.8,1.0]`' for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.5 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-3.0,-1.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -153,21 +127,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-3.0,-1.0] for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[1.0,3.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -177,21 +143,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[1.0,3.0]`' for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[3.0,28.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -201,21 +159,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[3.0,28.0]` for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-28.0,-3.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -225,21 +175,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-28.0,-3.0 for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[28.0,100.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -249,21 +191,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[28.0,100.0 for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arcsine on the interval `[-100.0,-28.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -273,13 +207,7 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-100.0,-28 for ( i = 0; i < x.length; i++ ) { y = asinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });