From 91dd0add808f7e63e01b874846d82503f83c7c07 Mon Sep 17 00:00:00 2001 From: yb175 Date: Sat, 3 Oct 2026 19:02:32 +0000 Subject: [PATCH] test: migrate math/base/special/atan to ULP-based testing --- .../base/special/atan/test/test.native.js | 133 ++---------------- 1 file changed, 14 insertions(+), 119 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/atan/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/atan/test/test.native.js index aa958036a88e..c9f43d3ffd7e 100644 --- a/lib/node_modules/@stdlib/math/base/special/atan/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/atan/test/test.native.js @@ -23,9 +23,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); @@ -68,8 +67,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the arctangent on the interval `[-1e-308,-1e-300]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -79,21 +76,13 @@ tape( 'the function computes the arctangent on the interval `[-1e-308,-1e-300]`' for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[1e-300,1e-308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -103,21 +92,13 @@ tape( 'the function computes the arctangent on the interval `[1e-300,1e-308]`', for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[-0.8,0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -127,21 +108,13 @@ tape( 'the function computes the arctangent on the interval `[-0.8,0.8]`', opts, for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[-1.0,-0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -151,21 +124,13 @@ tape( 'the function computes the arctangent on the interval `[-1.0,-0.8]`', opts for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[0.8,1.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -175,21 +140,13 @@ tape( 'the function computes the arctangent on the interval `[0.8,1.0]`', opts, for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[-3.0,-1.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -199,21 +156,13 @@ tape( 'the function computes the arctangent on the interval `[-3.0,-1.0]`', opts for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[1.0,3.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -223,21 +172,13 @@ tape( 'the function computes the arctangent on the interval `[1.0,3.0]`', opts, for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[3.0,100.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -247,21 +188,13 @@ tape( 'the function computes the arctangent on the interval `[3.0,100.0]`', opts for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[-100.0,-3.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -271,21 +204,13 @@ tape( 'the function computes the arctangent on the interval `[-100.0,-3.0]`', op for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[100.0,1000.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -295,21 +220,13 @@ tape( 'the function computes the arctangent on the interval `[100.0,1000.0]`', o for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[-1000.0,-100.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -319,21 +236,13 @@ tape( 'the function computes the arctangent on the interval `[-1000.0,-100.0]`', for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[-1e200,-1e208]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -343,21 +252,13 @@ tape( 'the function computes the arctangent on the interval `[-1e200,-1e208]`', for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the arctangent on the interval `[1e300,1e308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -367,13 +268,7 @@ tape( 'the function computes the arctangent on the interval `[1e300,1e308]`', op for ( i = 0; i < x.length; i++ ) { y = atan( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });