Skip to content

Commit b637ac8

Browse files
committed
test: migrate math/base/special/erf to ULP base testing
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4bfaa03 commit b637ac8

File tree

2 files changed

+26
-172
lines changed

2 files changed

+26
-172
lines changed

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

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
2626
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
2727
var NINF = require( '@stdlib/constants/float64/ninf' );
2828
var PINF = require( '@stdlib/constants/float64/pinf' );
29-
var EPS = require( '@stdlib/constants/float64/eps' );
30-
var abs = require( '@stdlib/math/base/special/abs' );
29+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
3130
var erf = require( './../lib' );
3231

3332

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

5857
tape( 'the function evaluates the error function for `x` on the interval `[-5,-100]', function test( t ) {
5958
var expected;
60-
var delta;
61-
var tol;
6259
var x;
6360
var y;
6461
var i;
@@ -67,21 +64,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[-5,-1
6764
x = veryLargeNegative.x;
6865
for ( i = 0; i < x.length; i++ ) {
6966
y = erf( x[i] );
70-
if ( y === expected[i] ) {
71-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
72-
} else {
73-
delta = abs( y - expected[ i ] );
74-
tol = EPS * abs( expected[ i ] );
75-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
76-
}
67+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
7768
}
7869
t.end();
7970
});
8071

8172
tape( 'the function evaluates the error function for `x` on the interval `[5,100]`', function test( t ) {
8273
var expected;
83-
var delta;
84-
var tol;
8574
var x;
8675
var y;
8776
var i;
@@ -90,21 +79,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[5,100
9079
x = veryLargePositive.x;
9180
for ( i = 0; i < x.length; i++ ) {
9281
y = erf( x[i] );
93-
if ( y === expected[i] ) {
94-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
95-
} else {
96-
delta = abs( y - expected[ i ] );
97-
tol = EPS * abs( expected[ i ] );
98-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
99-
}
82+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
10083
}
10184
t.end();
10285
});
10386

10487
tape( 'the function evaluates the error function for `x` on the interval `[-2.5,-5]`', function test( t ) {
10588
var expected;
106-
var delta;
107-
var tol;
10889
var x;
10990
var y;
11091
var i;
@@ -113,21 +94,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[-2.5,
11394
x = largeNegative.x;
11495
for ( i = 0; i < x.length; i++ ) {
11596
y = erf( x[i] );
116-
if ( y === expected[i] ) {
117-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
118-
} else {
119-
delta = abs( y - expected[ i ] );
120-
tol = EPS * abs( expected[ i ] );
121-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
122-
}
97+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
12398
}
12499
t.end();
125100
});
126101

127102
tape( 'the function evaluates the error function for `x` on the interval `[2.5,5]`', function test( t ) {
128103
var expected;
129-
var delta;
130-
var tol;
131104
var x;
132105
var y;
133106
var i;
@@ -136,21 +109,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[2.5,5
136109
x = largePositive.x;
137110
for ( i = 0; i < x.length; i++ ) {
138111
y = erf( x[i] );
139-
if ( y === expected[i] ) {
140-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
141-
} else {
142-
delta = abs( y - expected[ i ] );
143-
tol = EPS * abs( expected[ i ] );
144-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
145-
}
112+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
146113
}
147114
t.end();
148115
});
149116

150117
tape( 'the function evaluates the error function for `x` on the interval `[-1,-3]`', function test( t ) {
151118
var expected;
152-
var delta;
153-
var tol;
154119
var x;
155120
var y;
156121
var i;
@@ -159,21 +124,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[-1,-3
159124
x = mediumNegative.x;
160125
for ( i = 0; i < x.length; i++ ) {
161126
y = erf( x[i] );
162-
if ( y === expected[i] ) {
163-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
164-
} else {
165-
delta = abs( y - expected[ i ] );
166-
tol = EPS * abs( expected[ i ] );
167-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
168-
}
127+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
169128
}
170129
t.end();
171130
});
172131

173132
tape( 'the function evaluates the error function for `x` on the interval `[1,3]`', function test( t ) {
174133
var expected;
175-
var delta;
176-
var tol;
177134
var x;
178135
var y;
179136
var i;
@@ -182,13 +139,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[1,3]`
182139
x = mediumPositive.x;
183140
for ( i = 0; i < x.length; i++ ) {
184141
y = erf( x[i] );
185-
if ( y === expected[i] ) {
186-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
187-
} else {
188-
delta = abs( y - expected[ i ] );
189-
tol = EPS * abs( expected[ i ] );
190-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
191-
}
142+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
192143
}
193144
t.end();
194145
});
@@ -203,7 +154,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[-0.8,
203154
x = smallNegative.x;
204155
for ( i = 0; i < x.length; i++ ) {
205156
y = erf( x[i] );
206-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
157+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
207158
}
208159
t.end();
209160
});
@@ -218,7 +169,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[0.8,1
218169
x = smallPositive.x;
219170
for ( i = 0; i < x.length; i++ ) {
220171
y = erf( x[i] );
221-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
172+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
222173
}
223174
t.end();
224175
});
@@ -233,7 +184,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[-0.8,
233184
x = smaller.x;
234185
for ( i = 0; i < x.length; i++ ) {
235186
y = erf( x[i] );
236-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
187+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
237188
}
238189
t.end();
239190
});
@@ -248,7 +199,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[-1e-3
248199
x = tinyNegative.x;
249200
for ( i = 0; i < x.length; i++ ) {
250201
y = erf( x[i] );
251-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
202+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
252203
}
253204
t.end();
254205
});
@@ -263,7 +214,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[1e-30
263214
x = tinyPositive.x;
264215
for ( i = 0; i < x.length; i++ ) {
265216
y = erf( x[i] );
266-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
217+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
267218
}
268219
t.end();
269220
});
@@ -278,7 +229,7 @@ tape( 'the function evaluates the error function for subnormal `x`', function te
278229
x = subnormal.x;
279230
for ( i = 0; i < x.length; i++ ) {
280231
y = erf( x[i] );
281-
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
232+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
282233
}
283234
t.end();
284235
});

0 commit comments

Comments
 (0)