From c7751434fc3ab39ffa2bf593bfc57cb7fac21735 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 10 Jun 2026 02:33:37 -0500 Subject: [PATCH] test: migrate `math/base/special/cbrt` 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 --- --- .../base/special/cbrt/test/test.native.js | 142 ++---------------- 1 file changed, 14 insertions(+), 128 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.native.js index 00a606215163..6498072a8247 100644 --- a/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cbrt/test/test.native.js @@ -27,8 +27,6 @@ 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 tryRequire = require( '@stdlib/utils/try-require' ); @@ -68,8 +66,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function evaluates the cubic root of `x` on the interval `[-50,-500]', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -78,21 +74,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-50,-500]' x = veryLargeNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[50,500]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -101,21 +89,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[50,500]`', x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-50]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -124,21 +104,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-50]`' x = largeNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[20,50]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -147,21 +119,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[20,50]`', x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-3]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -170,21 +134,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-3]`', x = mediumNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[3,20]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -193,21 +149,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[3,20]`', o x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-3,-0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -216,21 +164,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-3,-0.8]`' x = smallNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[0.8,3]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -239,21 +179,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[0.8,3]`', x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates cubic root of `x` on the interval `[-0.8,0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -262,21 +194,13 @@ tape( 'the function evaluates cubic root of `x` on the interval `[-0.8,0.8]`', o x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[-1e-300,-1e-308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -285,21 +209,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-1e-300,-1 x = tinyNegative.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` on the interval `[1e-300,1e-308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -308,21 +224,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[1e-300,1e- x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of subnormal `x`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -331,21 +239,13 @@ tape( 'the function evaluates the cubic root of subnormal `x`', opts, function t x = subnormal.x; for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` (huge negative)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -355,21 +255,13 @@ tape( 'the function evaluates the cubic root of `x` (huge negative)', opts, func for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the cubic root of `x` (huge positive)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -379,13 +271,7 @@ tape( 'the function evaluates the cubic root of `x` (huge positive)', opts, func for ( i = 0; i < x.length; i++ ) { y = cbrt( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); });