From 12ac5033cd91b8c7c2d816dab5a81f4f3062543a Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 10 Jun 2026 02:10:04 -0500 Subject: [PATCH] test: migrate `math/base/special/sinh` to ULP-based testing --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/sinh/test/test.js | 53 +++---------------- .../base/special/sinh/test/test.native.js | 53 +++---------------- 2 files changed, 12 insertions(+), 94 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sinh/test/test.js b/lib/node_modules/@stdlib/math/base/special/sinh/test/test.js index ac0a950fb12a..7ed36172df10 100644 --- a/lib/node_modules/@stdlib/math/base/special/sinh/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sinh/test/test.js @@ -27,8 +27,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 sinh = require( './../lib' ); @@ -51,8 +50,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the hyperbolic sine', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -62,21 +59,13 @@ tape( 'the function computes the hyperbolic sine', function test( t ) { for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (large negative)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -86,21 +75,13 @@ tape( 'the function computes the hyperbolic sine (large negative)', function tes for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (large positive)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -110,21 +91,13 @@ tape( 'the function computes the hyperbolic sine (large positive)', function tes for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (tiny negative)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -134,21 +107,13 @@ tape( 'the function computes the hyperbolic sine (tiny negative)', function test for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (tiny positive)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -158,13 +123,7 @@ tape( 'the function computes the hyperbolic sine (tiny positive)', function test for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sinh/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sinh/test/test.native.js index fa3edacac969..c7a729084325 100644 --- a/lib/node_modules/@stdlib/math/base/special/sinh/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sinh/test/test.native.js @@ -28,8 +28,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 tryRequire = require( '@stdlib/utils/try-require' ); @@ -60,8 +59,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the hyperbolic sine', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -71,21 +68,13 @@ tape( 'the function computes the hyperbolic sine', opts, function test( t ) { for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (large negative)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -95,21 +84,13 @@ tape( 'the function computes the hyperbolic sine (large negative)', opts, functi for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (large positive)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -119,21 +100,13 @@ tape( 'the function computes the hyperbolic sine (large positive)', opts, functi for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (tiny negative)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -143,21 +116,13 @@ tape( 'the function computes the hyperbolic sine (tiny negative)', opts, functio for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic sine (tiny positive)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -167,13 +132,7 @@ tape( 'the function computes the hyperbolic sine (tiny positive)', opts, functio for ( i = 0; i < x.length; i++ ) { y = sinh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); });