Skip to content

Commit b2b7ddb

Browse files
authored
test: migrate math/base/special/asinh to ULP-based testing
PR-URL: #11654 Reviewed-by: Athan Reines <kgryte@gmail.com> Ref: #11352
1 parent 59d0640 commit b2b7ddb

1 file changed

Lines changed: 14 additions & 119 deletions

File tree

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

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

Lines changed: 14 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ 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 EPS = require( '@stdlib/constants/float64/eps' );
2827
var PINF = require( '@stdlib/constants/float64/pinf' );
2928
var NINF = require( '@stdlib/constants/float64/ninf' );
30-
var abs = require( '@stdlib/math/base/special/abs' );
29+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
3130
var asinh = require( './../lib' );
3231

3332

@@ -58,8 +57,6 @@ tape( 'main export is a function', function test( t ) {
5857

5958
tape( 'the function computes the hyperbolic arcsine on the interval `[-1e-308,-1e-300]`', function test( t ) {
6059
var expected;
61-
var delta;
62-
var tol;
6360
var x;
6461
var y;
6562
var i;
@@ -69,21 +66,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-1e-308,-1
6966

7067
for ( i = 0; i < x.length; i++ ) {
7168
y = asinh( x[i] );
72-
if ( y === expected[ i ] ) {
73-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
74-
} else {
75-
delta = abs( y - expected[i] );
76-
tol = 1.0 * EPS * abs( expected[i] );
77-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
78-
}
69+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
7970
}
8071
t.end();
8172
});
8273

8374
tape( 'the function computes the hyperbolic arcsine on the interval `[1e-300,1e-308]`', function test( t ) {
8475
var expected;
85-
var delta;
86-
var tol;
8776
var x;
8877
var y;
8978
var i;
@@ -93,21 +82,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[1e-300,1e-
9382

9483
for ( i = 0; i < x.length; i++ ) {
9584
y = asinh( x[i] );
96-
if ( y === expected[ i ] ) {
97-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
98-
} else {
99-
delta = abs( y - expected[i] );
100-
tol = 1.0 * EPS * abs( expected[i] );
101-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
102-
}
85+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
10386
}
10487
t.end();
10588
});
10689

10790
tape( 'the function computes the hyperbolic arcsine on the interval `[-0.8,0.8]`', function test( t ) {
10891
var expected;
109-
var delta;
110-
var tol;
11192
var x;
11293
var y;
11394
var i;
@@ -117,21 +98,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-0.8,0.8]`
11798

11899
for ( i = 0; i < x.length; i++ ) {
119100
y = asinh( x[i] );
120-
if ( y === expected[ i ] ) {
121-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
122-
} else {
123-
delta = abs( y - expected[i] );
124-
tol = 1.0 * EPS * abs( expected[i] );
125-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
126-
}
101+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
127102
}
128103
t.end();
129104
});
130105

131106
tape( 'the function computes the hyperbolic arcsine on the interval `[-1.0,-0.8]`', function test( t ) {
132107
var expected;
133-
var delta;
134-
var tol;
135108
var x;
136109
var y;
137110
var i;
@@ -141,21 +114,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-1.0,-0.8]
141114

142115
for ( i = 0; i < x.length; i++ ) {
143116
y = asinh( x[i] );
144-
if ( y === expected[ i ] ) {
145-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
146-
} else {
147-
delta = abs( y - expected[i] );
148-
tol = 1.0 * EPS * abs( expected[i] );
149-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
150-
}
117+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
151118
}
152119
t.end();
153120
});
154121

155122
tape( 'the function computes the hyperbolic arcsine on the interval `[0.8,1.0]`', function test( t ) {
156123
var expected;
157-
var delta;
158-
var tol;
159124
var x;
160125
var y;
161126
var i;
@@ -165,21 +130,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[0.8,1.0]`'
165130

166131
for ( i = 0; i < x.length; i++ ) {
167132
y = asinh( x[i] );
168-
if ( y === expected[ i ] ) {
169-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
170-
} else {
171-
delta = abs( y - expected[i] );
172-
tol = 1.0 * EPS * abs( expected[i] );
173-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
174-
}
133+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
175134
}
176135
t.end();
177136
});
178137

179138
tape( 'the function computes the hyperbolic arcsine on the interval `[-3.0,-1.0]`', function test( t ) {
180139
var expected;
181-
var delta;
182-
var tol;
183140
var x;
184141
var y;
185142
var i;
@@ -189,21 +146,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-3.0,-1.0]
189146

190147
for ( i = 0; i < x.length; i++ ) {
191148
y = asinh( x[i] );
192-
if ( y === expected[ i ] ) {
193-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
194-
} else {
195-
delta = abs( y - expected[i] );
196-
tol = 1.0 * EPS * abs( expected[i] );
197-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
198-
}
149+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
199150
}
200151
t.end();
201152
});
202153

203154
tape( 'the function computes the hyperbolic arcsine on the interval `[1.0,3.0]`', function test( t ) {
204155
var expected;
205-
var delta;
206-
var tol;
207156
var x;
208157
var y;
209158
var i;
@@ -213,21 +162,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[1.0,3.0]`'
213162

214163
for ( i = 0; i < x.length; i++ ) {
215164
y = asinh( x[i] );
216-
if ( y === expected[ i ] ) {
217-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
218-
} else {
219-
delta = abs( y - expected[i] );
220-
tol = 1.0 * EPS * abs( expected[i] );
221-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
222-
}
165+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
223166
}
224167
t.end();
225168
});
226169

227170
tape( 'the function computes the hyperbolic arcsine on the interval `[3.0,28.0]`', function test( t ) {
228171
var expected;
229-
var delta;
230-
var tol;
231172
var x;
232173
var y;
233174
var i;
@@ -237,21 +178,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[3.0,28.0]`
237178

238179
for ( i = 0; i < x.length; i++ ) {
239180
y = asinh( x[i] );
240-
if ( y === expected[ i ] ) {
241-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
242-
} else {
243-
delta = abs( y - expected[i] );
244-
tol = 1.0 * EPS * abs( expected[i] );
245-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
246-
}
181+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
247182
}
248183
t.end();
249184
});
250185

251186
tape( 'the function computes the hyperbolic arcsine on the interval `[-28.0,-3.0]`', function test( t ) {
252187
var expected;
253-
var delta;
254-
var tol;
255188
var x;
256189
var y;
257190
var i;
@@ -261,21 +194,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-28.0,-3.0
261194

262195
for ( i = 0; i < x.length; i++ ) {
263196
y = asinh( x[i] );
264-
if ( y === expected[ i ] ) {
265-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
266-
} else {
267-
delta = abs( y - expected[i] );
268-
tol = 1.0 * EPS * abs( expected[i] );
269-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
270-
}
197+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
271198
}
272199
t.end();
273200
});
274201

275202
tape( 'the function computes the hyperbolic arcsine on the interval `[28.0,100.0]`', function test( t ) {
276203
var expected;
277-
var delta;
278-
var tol;
279204
var x;
280205
var y;
281206
var i;
@@ -285,21 +210,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[28.0,100.0
285210

286211
for ( i = 0; i < x.length; i++ ) {
287212
y = asinh( x[i] );
288-
if ( y === expected[ i ] ) {
289-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
290-
} else {
291-
delta = abs( y - expected[i] );
292-
tol = 1.0 * EPS * abs( expected[i] );
293-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
294-
}
213+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
295214
}
296215
t.end();
297216
});
298217

299218
tape( 'the function computes the hyperbolic arcsine on the interval `[-100.0,-28.0]`', function test( t ) {
300219
var expected;
301-
var delta;
302-
var tol;
303220
var x;
304221
var y;
305222
var i;
@@ -309,21 +226,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-100.0,-28
309226

310227
for ( i = 0; i < x.length; i++ ) {
311228
y = asinh( x[i] );
312-
if ( y === expected[ i ] ) {
313-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
314-
} else {
315-
delta = abs( y - expected[i] );
316-
tol = 1.0 * EPS * abs( expected[i] );
317-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
318-
}
229+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
319230
}
320231
t.end();
321232
});
322233

323234
tape( 'the function computes the hyperbolic arcsine on the interval `[-1e200,-1e208]`', function test( t ) {
324235
var expected;
325-
var delta;
326-
var tol;
327236
var x;
328237
var y;
329238
var i;
@@ -333,21 +242,13 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[-1e200,-1e
333242

334243
for ( i = 0; i < x.length; i++ ) {
335244
y = asinh( x[i] );
336-
if ( y === expected[ i ] ) {
337-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
338-
} else {
339-
delta = abs( y - expected[i] );
340-
tol = 1.0 * EPS * abs( expected[i] );
341-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
342-
}
245+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
343246
}
344247
t.end();
345248
});
346249

347250
tape( 'the function computes the hyperbolic arcsine on the interval `[1e300,1e308]`', function test( t ) {
348251
var expected;
349-
var delta;
350-
var tol;
351252
var x;
352253
var y;
353254
var i;
@@ -357,13 +258,7 @@ tape( 'the function computes the hyperbolic arcsine on the interval `[1e300,1e30
357258

358259
for ( i = 0; i < x.length; i++ ) {
359260
y = asinh( x[i] );
360-
if ( y === expected[ i ] ) {
361-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
362-
} else {
363-
delta = abs( y - expected[i] );
364-
tol = 1.0 * EPS * abs( expected[i] );
365-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
366-
}
261+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
367262
}
368263
t.end();
369264
});

0 commit comments

Comments
 (0)