Skip to content

Commit e7b11ca

Browse files
committed
test: migrate math/base/special/acosh to ULP-based testing
1 parent 4fe7fa2 commit e7b11ca

File tree

2 files changed

+10
-74
lines changed

2 files changed

+10
-74
lines changed

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

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var randu = require( '@stdlib/random/base/randu' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
2727
var PINF = require( '@stdlib/constants/float64/pinf' );
28-
var abs = require( '@stdlib/math/base/special/abs' );
28+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2929
var isPositiveZero = require( '@stdlib/assert/is-positive-zero' );
3030
var acosh = require( './../lib' );
3131

@@ -48,8 +48,6 @@ tape( 'main export is a function', function test( t ) {
4848

4949
tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]', function test( t ) {
5050
var expected;
51-
var delta;
52-
var tol;
5351
var x;
5452
var y;
5553
var i;
@@ -59,21 +57,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]'
5957

6058
for ( i = 0; i < x.length; i++ ) {
6159
y = acosh( x[i] );
62-
if ( y === expected[ i ] ) {
63-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
64-
} else {
65-
delta = abs( y - expected[i] );
66-
tol = 1.0 * EPS * abs( expected[i] );
67-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
68-
}
60+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
6961
}
7062
t.end();
7163
});
7264

7365
tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]', function test( t ) {
7466
var expected;
75-
var delta;
76-
var tol;
7767
var x;
7868
var y;
7969
var i;
@@ -83,21 +73,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]
8373

8474
for ( i = 0; i < x.length; i++ ) {
8575
y = acosh( x[i] );
86-
if ( y === expected[ i ] ) {
87-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
88-
} else {
89-
delta = abs( y - expected[i] );
90-
tol = 1.0 * EPS * abs( expected[i] );
91-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
92-
}
76+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
9377
}
9478
t.end();
9579
});
9680

9781
tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.0]', function test( t ) {
9882
var expected;
99-
var delta;
100-
var tol;
10183
var x;
10284
var y;
10385
var i;
@@ -107,21 +89,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.
10789

10890
for ( i = 0; i < x.length; i++ ) {
10991
y = acosh( x[i] );
110-
if ( y === expected[ i ] ) {
111-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
112-
} else {
113-
delta = abs( y - expected[i] );
114-
tol = 1.0 * EPS * abs( expected[i] );
115-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
116-
}
92+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
11793
}
11894
t.end();
11995
});
12096

12197
tape( 'the function computes the hyperbolic arccosine for huge values', function test( t ) {
12298
var expected;
123-
var delta;
124-
var tol;
12599
var x;
126100
var y;
127101
var i;
@@ -131,13 +105,7 @@ tape( 'the function computes the hyperbolic arccosine for huge values', function
131105

132106
for ( i = 0; i < x.length; i++ ) {
133107
y = acosh( x[i] );
134-
if ( y === expected[ i ] ) {
135-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
136-
} else {
137-
delta = abs( y - expected[i] );
138-
tol = 1.0 * EPS * abs( expected[i] );
139-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
140-
}
108+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
141109
}
142110
t.end();
143111
});

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

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var randu = require( '@stdlib/random/base/randu' );
2727
var PINF = require( '@stdlib/constants/float64/pinf' );
2828
var EPS = require( '@stdlib/constants/float64/eps' );
29-
var abs = require( '@stdlib/math/base/special/abs' );
29+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
3030
var isPositiveZero = require( '@stdlib/assert/is-positive-zero' );
3131
var tryRequire = require( '@stdlib/utils/try-require' );
3232

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

5858
tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]', opts, function test( t ) {
5959
var expected;
60-
var delta;
61-
var tol;
6260
var x;
6361
var y;
6462
var i;
@@ -68,21 +66,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]'
6866

6967
for ( i = 0; i < x.length; i++ ) {
7068
y = acosh( x[i] );
71-
if ( y === expected[ i ] ) {
72-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
73-
} else {
74-
delta = abs( y - expected[i] );
75-
tol = 1.0 * EPS * abs( expected[i] );
76-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
77-
}
69+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
7870
}
7971
t.end();
8072
});
8173

8274
tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]', opts, function test( t ) {
8375
var expected;
84-
var delta;
85-
var tol;
8676
var x;
8777
var y;
8878
var i;
@@ -92,21 +82,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]
9282

9383
for ( i = 0; i < x.length; i++ ) {
9484
y = acosh( x[i] );
95-
if ( y === expected[ i ] ) {
96-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
97-
} else {
98-
delta = abs( y - expected[i] );
99-
tol = 1.0 * EPS * abs( expected[i] );
100-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
101-
}
85+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
10286
}
10387
t.end();
10488
});
10589

10690
tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.0]', opts, function test( t ) {
10791
var expected;
108-
var delta;
109-
var tol;
11092
var x;
11193
var y;
11294
var i;
@@ -116,21 +98,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.
11698

11799
for ( i = 0; i < x.length; i++ ) {
118100
y = acosh( x[i] );
119-
if ( y === expected[ i ] ) {
120-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
121-
} else {
122-
delta = abs( y - expected[i] );
123-
tol = 1.0 * EPS * abs( expected[i] );
124-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
125-
}
101+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
126102
}
127103
t.end();
128104
});
129105

130106
tape( 'the function computes the hyperbolic arccosine for huge values', opts, function test( t ) {
131107
var expected;
132-
var delta;
133-
var tol;
134108
var x;
135109
var y;
136110
var i;
@@ -140,13 +114,7 @@ tape( 'the function computes the hyperbolic arccosine for huge values', opts, fu
140114

141115
for ( i = 0; i < x.length; i++ ) {
142116
y = acosh( x[i] );
143-
if ( y === expected[ i ] ) {
144-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
145-
} else {
146-
delta = abs( y - expected[i] );
147-
tol = 1.0 * EPS * abs( expected[i] );
148-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
149-
}
117+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
150118
}
151119
t.end();
152120
});

0 commit comments

Comments
 (0)