From d16a56a6057b0e4247d0425f0f5413f027678cfa Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 10 Jun 2026 02:24:20 -0500 Subject: [PATCH] test: migrate `math/base/special/kernel-sin` 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 --- --- .../special/kernel-sin/test/test.native.js | 67 +++++-------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-sin/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-sin/test/test.native.js index 49953b586425..dfb8f88db9f7 100644 --- a/lib/node_modules/@stdlib/math/base/special/kernel-sin/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/kernel-sin/test/test.native.js @@ -24,8 +24,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var rempio2 = require( '@stdlib/math/base/special/rempio2' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -67,8 +66,6 @@ tape( 'the function returns `NaN` if provided `NaN` for either parameter', opts, tape( 'the function evaluates the sine for input values on the interval `[-pi/4, pi/4]`', opts, function test( t ) { var expected; var values; - var delta; - var tol; var out; var x; var i; @@ -78,15 +75,9 @@ tape( 'the function evaluates the sine for input values on the interval `[-pi/4, for ( i = 0; i < values.length; i++ ) { x = values[ i ]; out = kernelSin( x, 0.0 ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -94,8 +85,6 @@ tape( 'the function evaluates the sine for input values on the interval `[-pi/4, tape( 'the function can be used to compute the sine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (positive)', opts, function test( t ) { var expected; var values; - var delta; - var tol; var out; var x; var y; @@ -111,27 +100,15 @@ tape( 'the function can be used to compute the sine for input values outside of switch ( n & 3 ) { case 0: out = kernelSin( y[ 0 ], y[ 1 ] ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; case 2: out = -kernelSin( y[ 0 ], y[ 1 ] ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; default: break; @@ -143,8 +120,6 @@ tape( 'the function can be used to compute the sine for input values outside of tape( 'the function can be used to compute the sine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (negative)', opts, function test( t ) { var expected; var values; - var delta; - var tol; var out; var x; var y; @@ -160,27 +135,15 @@ tape( 'the function can be used to compute the sine for input values outside of switch ( n & 3 ) { case 0: out = kernelSin( y[ 0 ], y[ 1 ] ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; case 2: out = -kernelSin( y[ 0 ], y[ 1 ] ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; default: break;