diff --git a/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.js b/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.js index 121a34ef5556..b85ad1155634 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.js @@ -27,7 +27,7 @@ var NINF = require( '@stdlib/constants/float32/ninf' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); -var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); @@ -115,27 +115,22 @@ tape( 'the function returns `+0` if provided `+0`', function test( t ) { tape( 'the function supports rounding a numeric value to a desired number of decimals', function test( t ) { var expected; var actual; - var delta; actual = roundnf( PI, -2 ); expected = float64ToFloat32( 3.14 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( -PI, -2 ); expected = float64ToFloat32( -3.14 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( float64ToFloat32( 9.99999 ), -2 ); expected = float64ToFloat32( 10.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( float64ToFloat32( -9.99999 ), -2 ); expected = float64ToFloat32( -10.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( 0.0, 2 ); expected = 0.0; @@ -143,13 +138,11 @@ tape( 'the function supports rounding a numeric value to a desired number of dec actual = roundnf( float64ToFloat32( 12368.0 ), -3 ); expected = float64ToFloat32( 12368.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( float64ToFloat32( -12368.0 ), -3 ); expected = float64ToFloat32( -12368.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -157,14 +150,12 @@ tape( 'the function supports rounding a numeric value to a desired number of dec tape( 'rounding a numeric value to a desired number of decimals can result in unexpected behavior', function test( t ) { var expected; var actual; - var delta; var x; - x = float64ToFloat32( 0.2 + 0.1 ); // => 0.30000000000000004 as float64, becomes 0.30000001192092896 as float32 + x = float64ToFloat32( 0.2 + 0.1 ); // 0.30000000000000004 as float64, becomes 0.30000001192092896 as float32 actual = roundnf( x, -7 ); expected = float64ToFloat32( 0.3000000119209290 ); - delta = ulpdiff( actual, expected ); - t.ok( delta <= 1, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -172,7 +163,6 @@ tape( 'rounding a numeric value to a desired number of decimals can result in un tape( 'the function supports rounding a numeric value to a desired number of digits', function test( t ) { var expected; var actual; - var delta; actual = roundnf( PI, 3 ); expected = 0.0; @@ -180,8 +170,7 @@ tape( 'the function supports rounding a numeric value to a desired number of dig actual = roundnf( float64ToFloat32( 12368.0 ), 3 ); expected = float64ToFloat32( 12000.0 ); - delta = ulpdiff( actual, expected ); - t.ok( delta <= 1, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' ); actual = roundnf( float64ToFloat32( 12368.0 ), 1 ); expected = float64ToFloat32( 12370.0 ); @@ -192,8 +181,7 @@ tape( 'the function supports rounding a numeric value to a desired number of dig actual = roundnf( float64ToFloat32( -12368.0 ), 3 ); expected = float64ToFloat32( -12000.0 ); - delta = ulpdiff( actual, expected ); - t.ok( delta <= 1, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' ); actual = roundnf( float64ToFloat32( -12368.0 ), 1 ); expected = float64ToFloat32( -12370.0 ); @@ -261,7 +249,6 @@ tape( 'if `n > 38` (exceeds float32 max exponent), the function returns `+-0` (s tape( 'the function supports rounding very small numbers (including subnormals)', function test( t ) { var expected; var actual; - var delta; var x; var n; var i; @@ -287,8 +274,7 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { actual = roundnf( x, n[i] ); if ( i < expected.length ) { - delta = ulpdiff( actual, expected[i] ); - t.ok( delta <= 2, 'x: '+x+'. n: '+n[i]+'. v: '+actual+'. expected: '+expected[i]+'. delta: '+delta+' ulps' ); + t.strictEqual( isAlmostSameValue( actual, expected[i], 1 ), true, 'returns expected value' ); } else { // Beyond float32 precision t.ok( true, 'x: '+x+'. n: '+n[i]+'. v: '+actual ); diff --git a/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.native.js index 93076ec9eecd..b1d55bd049b2 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundnf/test/test.native.js @@ -28,7 +28,7 @@ var NINF = require( '@stdlib/constants/float32/ninf' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); -var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); @@ -109,27 +109,22 @@ tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { tape( 'the function supports rounding a numeric value to a desired number of decimals', opts, function test( t ) { var expected; var actual; - var delta; actual = roundnf( PI, -2 ); expected = float64ToFloat32( 3.14 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( -PI, -2 ); expected = float64ToFloat32( -3.14 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( float64ToFloat32( 9.99999 ), -2 ); expected = float64ToFloat32( 10.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( float64ToFloat32( -9.99999 ), -2 ); expected = float64ToFloat32( -10.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( 0.0, 2 ); expected = 0.0; @@ -137,13 +132,11 @@ tape( 'the function supports rounding a numeric value to a desired number of dec actual = roundnf( float64ToFloat32( 12368.0 ), -3 ); expected = float64ToFloat32( 12368.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); actual = roundnf( float64ToFloat32( -12368.0 ), -3 ); expected = float64ToFloat32( -12368.0 ); - delta = ulpdiff( actual, expected ); - t.strictEqual( delta, 0, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -151,14 +144,12 @@ tape( 'the function supports rounding a numeric value to a desired number of dec tape( 'rounding a numeric value to a desired number of decimals can result in unexpected behavior', opts, function test( t ) { var expected; var actual; - var delta; var x; x = float64ToFloat32( 0.2 + 0.1 ); actual = roundnf( x, -7 ); expected = float64ToFloat32( 0.3000000119209290 ); - delta = ulpdiff( actual, expected ); - t.ok( delta <= 1, 'returns expected value' ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -166,7 +157,6 @@ tape( 'rounding a numeric value to a desired number of decimals can result in un tape( 'the function supports rounding a numeric value to a desired number of digits', opts, function test( t ) { var expected; var actual; - var delta; actual = roundnf( PI, 3 ); expected = 0.0; @@ -174,8 +164,7 @@ tape( 'the function supports rounding a numeric value to a desired number of dig actual = roundnf( float64ToFloat32( 12368.0 ), 3 ); expected = float64ToFloat32( 12000.0 ); - delta = ulpdiff( actual, expected ); - t.ok( delta <= 1, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' ); actual = roundnf( float64ToFloat32( 12368.0 ), 1 ); expected = float64ToFloat32( 12370.0 ); @@ -186,8 +175,7 @@ tape( 'the function supports rounding a numeric value to a desired number of dig actual = roundnf( float64ToFloat32( -12368.0 ), 3 ); expected = float64ToFloat32( -12000.0 ); - delta = ulpdiff( actual, expected ); - t.ok( delta <= 1, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' ); actual = roundnf( float64ToFloat32( -12368.0 ), 1 ); expected = float64ToFloat32( -12370.0 ); @@ -255,7 +243,6 @@ tape( 'if `n > 38` (exceeds float32 max exponent), the function returns `+-0` (s tape( 'the function supports rounding very small numbers (including subnormals)', opts, function test( t ) { var expected; var actual; - var delta; var x; var n; var i; @@ -280,8 +267,7 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { actual = roundnf( x, n[i] ); if ( i < expected.length ) { - delta = ulpdiff( actual, expected[i] ); - t.ok( delta <= 2, 'x: '+x+'. n: '+n[i]+'. v: '+actual+'. expected: '+expected[i]+'. delta: '+delta+' ulps' ); + t.strictEqual( isAlmostSameValue( actual, expected[i], 1 ), true, 'returns expected value' ); } else { t.ok( true, 'x: '+x+'. n: '+n[i]+'. v: '+actual ); }