From 2fb1f1f4f7b4ce8d17a54aa8fc619acb6991c560 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Aug 2026 21:15:29 +0000 Subject: [PATCH] test: migrate `math/base/special/cfloorn` to ULP-based assertions Resolves a part of #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 --- --- .../math/base/special/cfloorn/test/test.js | 18 +++--------------- .../base/special/cfloorn/test/test.native.js | 18 +++--------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.js b/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.js index 4e7ae286782b..23ea65131a76 100644 --- a/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.js @@ -21,14 +21,13 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); -var abs = require( '@stdlib/math/base/special/abs' ); 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' ); @@ -262,8 +261,6 @@ tape( 'if `n > 308` and a component is greater than or equal to zero, the functi tape( 'the function supports rounding very small numbers (including subnormals)', function test( t ) { var expected; - var delta; - var tol; var x; var n; var v; @@ -297,17 +294,8 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { v = cfloorn( new Complex128( x, x ), n[i] ); - if ( real( v ) === expected[i] ) { - t.strictEqual( real( v ), expected[i], 'returns '+expected[i]+' when provided re='+x+', im='+x+', and n='+n[i]+'.' ); - } else { - delta = abs( real( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 're: '+x+'. n: '+n[i]+'. v: '+real( v )+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - - delta = abs( imag( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'im: '+x+'. n: '+n[i]+'. v: '+imag( v )+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( real( v ), expected[i], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( v ), expected[i], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.native.js index 03bb17c8d312..704d525540a9 100644 --- a/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cfloorn/test/test.native.js @@ -22,13 +22,12 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); -var abs = require( '@stdlib/math/base/special/abs' ); 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' ); @@ -234,8 +233,6 @@ tape( 'if `n > 308` and a component is greater than or equal to zero, the functi tape( 'the function supports rounding very small numbers (including subnormals)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var n; var v; @@ -269,17 +266,8 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { v = cfloorn( new Complex128( x, x ), n[i] ); - if ( real( v ) === expected[i] ) { - t.strictEqual( real( v ), expected[i], 'returns '+expected[i]+' when provided re='+x+', im='+x+', and n='+n[i]+'.' ); - } else { - delta = abs( real( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 're: '+x+'. n: '+n[i]+'. v: '+real( v )+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - - delta = abs( imag( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'im: '+x+'. n: '+n[i]+'. v: '+imag( v )+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( real( v ), expected[i], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( v ), expected[i], 1 ), true, 'returns expected value' ); } t.end(); });