From 0a6c7b89d0701e3747bf2d12b171b9feda1b2f21 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 1 Aug 2026 09:16:05 +0000 Subject: [PATCH] test: migrate `math/base/special/csc` to ULP-based testing Replaces the EPS-based relative tolerance assertions with `@stdlib/assert/is-almost-same-value` ULP-difference assertions, tightened to the minimum required ULP per fixture range: - huge (negative/positive): 2 ULP - very large (negative/positive): 1 ULP - large/medium/small/smaller/tiny: exact (plain `strictEqual`) Resolves a part of #11352. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01MeLecApUxretH11SrzxudS --- .../math/base/special/csc/test/test.js | 159 +++--------------- .../math/base/special/csc/test/test.native.js | 133 ++------------- 2 files changed, 41 insertions(+), 251 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/csc/test/test.js b/lib/node_modules/@stdlib/math/base/special/csc/test/test.js index 7d711bfb92d7..4e36a59d678b 100644 --- a/lib/node_modules/@stdlib/math/base/special/csc/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/csc/test/test.js @@ -22,11 +22,10 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); var PI = require( '@stdlib/constants/float64/pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var csc = require( './../lib' ); @@ -57,8 +56,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the cosecant (huge negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -67,22 +64,14 @@ tape( 'the function computes the cosecant (huge negative values)', function test expected = hugeNegative.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (huge positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -91,22 +80,14 @@ tape( 'the function computes the cosecant (huge positive values)', function test expected = hugePositive.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (very large positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -115,22 +96,14 @@ tape( 'the function computes the cosecant (very large positive values)', functio expected = veryLargePositive.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (very large negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -139,22 +112,14 @@ tape( 'the function computes the cosecant (very large negative values)', functio expected = veryLargeNegative.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (large positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -163,22 +128,14 @@ tape( 'the function computes the cosecant (large positive values)', function tes expected = largePositive.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (large negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -187,22 +144,14 @@ tape( 'the function computes the cosecant (large negative values)', function tes expected = largeNegative.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (medium positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -211,22 +160,14 @@ tape( 'the function computes the cosecant (medium positive values)', function te expected = mediumPositive.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (medium negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -235,22 +176,14 @@ tape( 'the function computes the cosecant (medium negative values)', function te expected = mediumNegative.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (small positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -259,22 +192,14 @@ tape( 'the function computes the cosecant (small positive values)', function tes expected = smallPositive.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (small negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -283,22 +208,14 @@ tape( 'the function computes the cosecant (small negative values)', function tes expected = smallNegative.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (smaller values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -307,22 +224,14 @@ tape( 'the function computes the cosecant (smaller values)', function test( t ) expected = smaller.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (tiny positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -331,22 +240,14 @@ tape( 'the function computes the cosecant (tiny positive values)', function test expected = tinyPositive.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (tiny negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -355,14 +256,8 @@ tape( 'the function computes the cosecant (tiny negative values)', function test expected = tinyNegative.expected; for ( i = 0; i < x.length; i++ ) { - y = csc(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.4 * EPS * abs(expected[i]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + y = csc( x[ i ] ); + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/csc/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/csc/test/test.native.js index d73f1bc2b930..446b20fa19bb 100644 --- a/lib/node_modules/@stdlib/math/base/special/csc/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/csc/test/test.native.js @@ -23,11 +23,10 @@ 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 PI = require( '@stdlib/constants/float64/pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -66,8 +65,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the cosecant (huge negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -77,21 +74,13 @@ tape( 'the function computes the cosecant (huge negative values)', opts, functio for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * 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 ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (huge positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -101,21 +90,13 @@ tape( 'the function computes the cosecant (huge positive values)', opts, functio for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * 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 ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (very large positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -125,21 +106,13 @@ tape( 'the function computes the cosecant (very large positive values)', opts, f for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * 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 cosecant (very large negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -149,21 +122,13 @@ tape( 'the function computes the cosecant (very large negative values)', opts, f for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * 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 cosecant (large positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -173,21 +138,13 @@ tape( 'the function computes the cosecant (large positive values)', opts, functi for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (large negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -197,21 +154,13 @@ tape( 'the function computes the cosecant (large negative values)', opts, functi for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (medium positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -221,21 +170,13 @@ tape( 'the function computes the cosecant (medium positive values)', opts, funct for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (medium negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -245,21 +186,13 @@ tape( 'the function computes the cosecant (medium negative values)', opts, funct for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (small positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -269,21 +202,13 @@ tape( 'the function computes the cosecant (small positive values)', opts, functi for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (small negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -293,21 +218,13 @@ tape( 'the function computes the cosecant (small negative values)', opts, functi for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (smaller values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -317,21 +234,13 @@ tape( 'the function computes the cosecant (smaller values)', opts, function test for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (tiny positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -341,21 +250,13 @@ tape( 'the function computes the cosecant (tiny positive values)', opts, functio for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the cosecant (tiny negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -365,13 +266,7 @@ tape( 'the function computes the cosecant (tiny negative values)', opts, functio for ( i = 0; i < x.length; i++ ) { y = csc( 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.4 * EPS * abs(expected[ i ]); - t.ok(delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.'); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); });