Skip to content

Commit 165fd95

Browse files
authored
test: migrate math/base/special/atan2 to ULP-based testing
PR-URL: #11658 Reviewed-by: Athan Reines <kgryte@gmail.com> Ref: #11352
1 parent 0eafdb6 commit 165fd95

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

  • lib/node_modules/@stdlib/math/base/special/atan2/test

lib/node_modules/@stdlib/math/base/special/atan2/test/test.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
2626
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
27-
var abs = require( '@stdlib/math/base/special/abs' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
27+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2928
var PINF = require( '@stdlib/constants/float64/pinf' );
3029
var NINF = require( '@stdlib/constants/float64/ninf' );
3130
var PI = require( '@stdlib/constants/float64/pi' );
@@ -187,8 +186,6 @@ tape( 'the function returns `-PI/2` if provided a negative `y` and `x=-0`', func
187186
tape( 'the function evaluates the `atan2` function (when x and y are positive)', function test( t ) {
188187
var expected;
189188
var actual;
190-
var delta;
191-
var tol;
192189
var x;
193190
var y;
194191
var i;
@@ -198,18 +195,14 @@ tape( 'the function evaluates the `atan2` function (when x and y are positive)',
198195
expected = positivePositive.expected;
199196
for ( i = 0; i < x.length; i++ ) {
200197
actual = atan2( y[i], x[i] );
201-
delta = abs( actual - expected[i] );
202-
tol = EPS * abs( expected[i] );
203-
t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
198+
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' );
204199
}
205200
t.end();
206201
});
207202

208203
tape( 'the function evaluates the `atan2` function (when x is negative and y is positive)', function test( t ) {
209204
var expected;
210205
var actual;
211-
var delta;
212-
var tol;
213206
var x;
214207
var y;
215208
var i;
@@ -219,18 +212,14 @@ tape( 'the function evaluates the `atan2` function (when x is negative and y is
219212
expected = negativePositive.expected;
220213
for ( i = 0; i < x.length; i++ ) {
221214
actual = atan2( y[i], x[i] );
222-
delta = abs( actual - expected[i] );
223-
tol = 2.0 * EPS * abs( expected[i] );
224-
t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
215+
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' );
225216
}
226217
t.end();
227218
});
228219

229220
tape( 'the function evaluates the `atan2` function (when x and y are negative)', function test( t ) {
230221
var expected;
231222
var actual;
232-
var delta;
233-
var tol;
234223
var x;
235224
var y;
236225
var i;
@@ -240,9 +229,7 @@ tape( 'the function evaluates the `atan2` function (when x and y are negative)',
240229
expected = negativeNegative.expected;
241230
for ( i = 0; i < x.length; i++ ) {
242231
actual = atan2( y[i], x[i] );
243-
delta = abs( actual - expected[i] );
244-
tol = 2.0 * EPS * abs( expected[i] );
245-
t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
232+
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' );
246233
}
247234
t.end();
248235
});

0 commit comments

Comments
 (0)