From f89b92a35dd8e2147170de1a5afcc5a3fe097aa8 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 10 Jun 2026 02:26:28 -0500 Subject: [PATCH] test: migrate `math/base/special/sincos` 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/sincos/test/test.assign.js | 110 ++------------ .../base/special/sincos/test/test.main.js | 110 ++------------ .../base/special/sincos/test/test.native.js | 135 +++++------------- 3 files changed, 61 insertions(+), 294 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sincos/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/sincos/test/test.assign.js index d4e2b9063444..65f7c58bac64 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincos/test/test.assign.js +++ b/lib/node_modules/@stdlib/math/base/special/sincos/test/test.assign.js @@ -24,8 +24,6 @@ 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 Float64Array = require( '@stdlib/array/float64' ); var sincos = require( './../lib/assign.js' ); @@ -50,9 +48,7 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -66,29 +62,15 @@ tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', functio for ( i = 0; i < x.length; i++ ) { y = sincos( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -102,29 +84,15 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', function for ( i = 0; i < x.length; i++ ) { y = sincos( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 (pi/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -138,29 +106,15 @@ tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 for ( i = 0; i < x.length; i++ ) { y = sincos( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 (pi/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -174,29 +128,15 @@ tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 ( for ( i = 0; i < x.length; i++ ) { y = sincos( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -210,29 +150,15 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', func for ( i = 0; i < x.length; i++ ) { y = sincos( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -246,20 +172,8 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', funct for ( i = 0; i < x.length; i++ ) { y = sincos( x[i], z, 1, 0 ); t.strictEqual( y, z, 'returns output array' ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sincos/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/sincos/test/test.main.js index 9c77f2040e6c..8a34268f00de 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincos/test/test.main.js +++ b/lib/node_modules/@stdlib/math/base/special/sincos/test/test.main.js @@ -24,8 +24,6 @@ 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 sincos = require( './../lib/main.js' ); @@ -49,9 +47,7 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -62,29 +58,15 @@ tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', functio for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -95,29 +77,15 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', function for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 (pi/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -128,29 +96,15 @@ tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 (pi/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -161,29 +115,15 @@ tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 ( for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -194,29 +134,15 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', func for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -227,20 +153,8 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', funct for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' ); + t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sincos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sincos/test/test.native.js index 2306b02b1954..b23d5095d187 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincos/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sincos/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 tryRequire = require( '@stdlib/utils/try-require' ); @@ -58,9 +57,7 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -71,29 +68,19 @@ tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', opts, f for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -104,29 +91,19 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', opts, fu for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 (pi/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -137,29 +114,19 @@ tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 (pi/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -170,29 +137,19 @@ tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 ( for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -203,29 +160,19 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', opts for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', opts, function test( t ) { var cosine; - var delta; var sine; - var tol; var x; var y; var i; @@ -236,20 +183,12 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', opts, for ( i = 0; i < x.length; i++ ) { y = sincos( x[i] ); - if ( y[0] === sine[ i ] ) { - t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] ); - } else { - delta = abs( y[0] - sine[i] ); - tol = EPS * abs( sine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } - if ( y[1] === cosine[ i ] ) { - t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] ); - } else { - delta = abs( y[1] - cosine[i] ); - tol = EPS * abs( cosine[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], 1 ), true, 'returns expected value' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( y[ 1 ], cosine[ i ], 1 ), true, 'returns expected value' ); } t.end(); });