From 99da2028b59d7bfddae0d735f6aa78a981004086 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 8 Sep 2026 14:27:23 +0000 Subject: [PATCH] test: migrate `simulate/iter/sawtooth-wave` to ULP-based assertions Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01WqqdPYJ7b95CKX13XpdtDH --- .../simulate/iter/sawtooth-wave/test/test.js | 83 ++----------------- 1 file changed, 9 insertions(+), 74 deletions(-) diff --git a/lib/node_modules/@stdlib/simulate/iter/sawtooth-wave/test/test.js b/lib/node_modules/@stdlib/simulate/iter/sawtooth-wave/test/test.js index 1096dba8cb9c..faa3adab82aa 100644 --- a/lib/node_modules/@stdlib/simulate/iter/sawtooth-wave/test/test.js +++ b/lib/node_modules/@stdlib/simulate/iter/sawtooth-wave/test/test.js @@ -22,11 +22,10 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var iteratorSymbol = require( '@stdlib/symbol/iterator' ); var tan = require( '@stdlib/math/base/special/tan' ); var atan = require( '@stdlib/math/base/special/atan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var HALF_PI = require( '@stdlib/constants/float64/half-pi' ); var PI = require( '@stdlib/constants/float64/pi' ); var iterSawtoothWave = require( './../lib' ); @@ -103,8 +102,6 @@ tape( 'the function throws an error if provided an invalid option', function tes tape( 'the function returns an iterator protocol-compliant object which generates a sawtooth wave', function test( t ) { var expected; var actual; - var delta; - var tol; var it; var i; @@ -165,13 +162,7 @@ tape( 'the function returns an iterator protocol-compliant object which generate for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -179,9 +170,7 @@ tape( 'the function returns an iterator protocol-compliant object which generate tape( 'the function supports specifying the waveform period', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -245,13 +234,7 @@ tape( 'the function supports specifying the waveform period', function test( t ) for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -259,9 +242,7 @@ tape( 'the function supports specifying the waveform period', function test( t ) tape( 'the function supports specifying the wave amplitude', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -326,13 +307,7 @@ tape( 'the function supports specifying the wave amplitude', function test( t ) for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -340,9 +315,7 @@ tape( 'the function supports specifying the wave amplitude', function test( t ) tape( 'the function supports specifying the phase offset (left shift)', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -407,13 +380,7 @@ tape( 'the function supports specifying the phase offset (left shift)', function for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -421,9 +388,7 @@ tape( 'the function supports specifying the phase offset (left shift)', function tape( 'the function supports specifying the phase offset (left shift; mod)', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -488,13 +453,7 @@ tape( 'the function supports specifying the phase offset (left shift; mod)', fun for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -502,9 +461,7 @@ tape( 'the function supports specifying the phase offset (left shift; mod)', fun tape( 'the function supports specifying the phase offset (right shift)', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -569,13 +526,7 @@ tape( 'the function supports specifying the phase offset (right shift)', functio for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -583,9 +534,7 @@ tape( 'the function supports specifying the phase offset (right shift)', functio tape( 'the function supports specifying the phase offset (right shift; mod)', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -650,13 +599,7 @@ tape( 'the function supports specifying the phase offset (right shift; mod)', fu for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -664,9 +607,7 @@ tape( 'the function supports specifying the phase offset (right shift; mod)', fu tape( 'the function supports limiting the number of iterations', function test( t ) { var expected; var actual; - var delta; var opts; - var tol; var it; var i; @@ -702,13 +643,7 @@ tape( 'the function supports limiting the number of iterations', function test( for ( i = 0; i < expected.length; i++ ) { actual = it.next(); t.strictEqual( actual.done, expected[ i ].done, 'returns expected value' ); - if ( actual.value === expected[ i ].value ) { - t.strictEqual( actual.value, expected[ i ].value, 'returns expected value' ); - } else { - delta = abs( actual.value - expected[ i ].value ); - tol = 1.0 * EPS * abs( expected[ i ].value ); - t.strictEqual( delta <= tol, true, 'within tolerance. i: '+i+'. actual: '+actual.value+'. expected: '+expected[ i ].value+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual.value, expected[ i ].value, 1 ), true, 'returns expected value' ); } t.end(); });