Skip to content

Commit 6325a9f

Browse files
committed
test(math/base/special/powm1): migrate relative tolerance check to ULP
1 parent e1cc737 commit 6325a9f

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

‎lib/node_modules/@stdlib/math/base/special/powm1/test/test.js‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2425
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var abs = require( '@stdlib/math/base/special/abs' );
2726
var expm1 = require( '@stdlib/math/base/special/expm1' );
2827
var ln = require( '@stdlib/math/base/special/ln' );
29-
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var randu = require( '@stdlib/random/base/randu' );
3029
var powm1 = require( './../lib' );
3130

3231

@@ -72,8 +71,6 @@ tape( 'if provided a base equal to `0`, the function returns `-1` (except when t
7271

7372
tape( 'the function evaluates `bˣ - 1` (tested against Boost)', function test( t ) {
7473
var expected;
75-
var delta;
76-
var tol;
7774
var b;
7875
var x;
7976
var y;
@@ -85,9 +82,11 @@ tape( 'the function evaluates `bˣ - 1` (tested against Boost)', function test(
8582

8683
for ( i = 0; i < b.length; i++ ) {
8784
y = powm1( b[ i ], x[ i ] );
88-
delta = abs( y - expected[ i ] );
89-
tol = 2.0 * EPS * abs( expected[ i ] );
90-
t.ok( delta <= tol, 'within tolerance. b: ' + b[ i ] + 'x: ' + x[ i ] + '. actual: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
85+
if ( y === expected[ i ] ) {
86+
t.strictEqual( y, expected[ i ], 'returns '+expected[ i ]+' when provided b: '+b[ i ]+', x: '+x[ i ] );
87+
} else {
88+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value. b: '+b[ i ]+', x: '+x[ i ] );
89+
}
9190
}
9291
t.end();
9392
});

‎lib/node_modules/@stdlib/math/base/special/powm1/test/test.native.js‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
25+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26-
var randu = require( '@stdlib/random/base/randu' );
27-
var abs = require( '@stdlib/math/base/special/abs' );
2827
var expm1 = require( '@stdlib/math/base/special/expm1' );
2928
var ln = require( '@stdlib/math/base/special/ln' );
30-
var EPS = require( '@stdlib/constants/float64/eps' );
29+
var randu = require( '@stdlib/random/base/randu' );
3130
var tryRequire = require( '@stdlib/utils/try-require' );
3231

3332

@@ -81,8 +80,6 @@ tape( 'if provided a base equal to `0`, the function returns `-1` (except when t
8180

8281
tape( 'the function evaluates `bˣ - 1` (tested against Boost)', opts, function test( t ) {
8382
var expected;
84-
var delta;
85-
var tol;
8683
var b;
8784
var x;
8885
var y;
@@ -94,9 +91,11 @@ tape( 'the function evaluates `bˣ - 1` (tested against Boost)', opts, function
9491

9592
for ( i = 0; i < b.length; i++ ) {
9693
y = powm1( b[ i ], x[ i ] );
97-
delta = abs( y - expected[ i ] );
98-
tol = 2.0 * EPS * abs( expected[ i ] );
99-
t.ok( delta <= tol, 'within tolerance. b: ' + b[ i ] + 'x: ' + x[ i ] + '. actual: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
94+
if ( y === expected[ i ] ) {
95+
t.strictEqual( y, expected[ i ], 'returns '+expected[ i ]+' when provided b: '+b[ i ]+', x: '+x[ i ] );
96+
} else {
97+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value. b: '+b[ i ]+', x: '+x[ i ] );
98+
}
10099
}
101100
t.end();
102101
});

0 commit comments

Comments
 (0)