From 5ab67ed197c0f6bf0e7b78350ffa5d1d042c1ace Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Sun, 26 Jul 2026 17:35:41 +0530 Subject: [PATCH] test: migrate math/base/special/fresnels to ULP-based testing --- .../math/base/special/fresnels/test/test.js | 43 +++---------------- .../base/special/fresnels/test/test.native.js | 43 +++---------------- 2 files changed, 10 insertions(+), 76 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.js b/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.js index dc5bed23daba..f2b0bc8dedff 100644 --- a/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.js @@ -24,8 +24,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var randu = require( '@stdlib/random/base/randu' ); var fresnels = require( './../lib' ); @@ -47,8 +46,6 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function computes the S(x) term of the Fresnel integral (small positive values)', function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -59,20 +56,12 @@ tape( 'the function computes the S(x) term of the Fresnel integral (small positi for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 4.0 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 4 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the S(x) term of the Fresnel integral (medium positive values)', function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -83,20 +72,12 @@ tape( 'the function computes the S(x) term of the Fresnel integral (medium posit for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 1.5 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the S(x) term of the Fresnel integral (large positive values)', function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -107,20 +88,12 @@ tape( 'the function computes the S(x) term of the Fresnel integral (large positi for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 1.5 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the S(x) term of the Fresnel integral (very large positive values)', function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -131,13 +104,7 @@ tape( 'the function computes the S(x) term of the Fresnel integral (very large p for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 1.5 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.native.js index e07428556abe..4c6916f1b9b0 100644 --- a/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fresnels/test/test.native.js @@ -25,8 +25,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var randu = require( '@stdlib/random/base/randu' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -56,8 +55,6 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function computes the S(x) term of the Fresnel integral (small positive values)', opts, function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -68,20 +65,12 @@ tape( 'the function computes the S(x) term of the Fresnel integral (small positi for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 4.0 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 4 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the S(x) term of the Fresnel integral (medium positive values)', opts, function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -92,20 +81,12 @@ tape( 'the function computes the S(x) term of the Fresnel integral (medium posit for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 1.5 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the S(x) term of the Fresnel integral (large positive values)', opts, function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -116,20 +97,12 @@ tape( 'the function computes the S(x) term of the Fresnel integral (large positi for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 1.5 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the S(x) term of the Fresnel integral (very large positive values)', opts, function test( t ) { - var delta; - var tol; var S; var x; var y; @@ -140,13 +113,7 @@ tape( 'the function computes the S(x) term of the Fresnel integral (very large p for ( i = 0; i < x.length; i++ ) { y = fresnels( x[i] ); - if ( y === S[ i ] ) { - t.strictEqual( y, S[ i ], 'x: '+x[i]+'. Expected: '+S[i] ); - } else { - delta = abs( y - S[i] ); - tol = 1.5 * EPS * abs( S[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+S[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, S[ i ], 1 ), true, 'returns expected value' ); } t.end(); });