From 86e4bb1b25d7913d48323ea7eb14bc481a9772b3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Aug 2026 21:14:33 +0000 Subject: [PATCH] test: migrate math/base/special/binomcoeff native tests to ULP-based assertions Replaces the manual delta/tolerance comparison in test.native.js with isAlmostSameValue, mirroring the pattern already used in test.js for this package. The tightest ULP bound found is 2 (matches the JS binding's bound). Ref: #11352 --- 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: skipped - 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 --- --- .../base/special/binomcoeff/test/test.native.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.native.js index af0415643c12..50288b659440 100644 --- a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var absf = require( '@stdlib/math/base/special/absf' ); -var EPS = require( '@stdlib/constants/float32/eps' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -52,8 +51,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function evaluates the binomial coefficient for integers `n` and `k`', opts, function test( t ) { var expected; - var delta; - var tol; var n; var k; var v; @@ -65,15 +62,9 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k`' for ( i = 0; i < n.length; i++ ) { v = binomcoeff( n[ i ], k[ i ] ); expected[ i ] = float64ToFloat32( expected[ i ] ); - if ( expected[ i ] === v ) { - t.strictEqual( v, expected[ i ], 'returns expected value' ); - continue; - } - delta = absf( v - expected[ i ] ); // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. - tol = 1.25 * EPS * absf( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. n: ' + n[ i ] + '. k: ' + k[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); });