From 09c95dd1a8415c7881159d1c358b814b5161f2cf Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 26 Sep 2026 18:32:46 +0000 Subject: [PATCH] test: migrate `simulate/iter/triangle-wave` to ULP-based assertions Replace relative tolerance comparisons with `isAlmostSameValue` ULP difference assertions. Each assertion site uses the minimum required ULP value, which is `0` throughout, as the returned values are bit-identical to the expected values. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01UDitDiLoTNhLZNVBzzdAYE --- 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 --- --- .../simulate/iter/triangle-wave/test/test.js | 83 ++----------------- 1 file changed, 9 insertions(+), 74 deletions(-) diff --git a/lib/node_modules/@stdlib/simulate/iter/triangle-wave/test/test.js b/lib/node_modules/@stdlib/simulate/iter/triangle-wave/test/test.js index 462c364b61c6..6514292f6897 100644 --- a/lib/node_modules/@stdlib/simulate/iter/triangle-wave/test/test.js +++ b/lib/node_modules/@stdlib/simulate/iter/triangle-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 sinpi = require( '@stdlib/math/base/special/sinpi' ); var asin = require( '@stdlib/math/base/special/asin' ); -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 iterTriangleWave = require( './../lib' ); @@ -102,8 +101,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 triangle wave', function test( t ) { var expected; var actual; - var delta; - var tol; var it; var i; @@ -164,13 +161,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(); }); @@ -178,9 +169,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; @@ -244,13 +233,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(); }); @@ -258,9 +241,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; @@ -325,13 +306,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(); }); @@ -339,9 +314,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; @@ -406,13 +379,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(); }); @@ -420,9 +387,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; @@ -487,13 +452,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(); }); @@ -501,9 +460,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; @@ -568,13 +525,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(); }); @@ -582,9 +533,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; @@ -649,13 +598,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(); }); @@ -663,9 +606,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; @@ -701,13 +642,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, 0 ), true, 'returns expected value' ); } t.end(); });