Skip to content

Commit 0cfeaa3

Browse files
committed
test: migrate math/base/special/erfc 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 0cfeaa3

2 files changed

Lines changed: 21 additions & 99 deletions

File tree

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

Lines changed: 8 additions & 37 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 NINF = require( '@stdlib/constants/float64/ninf' );
2626
var PINF = require( '@stdlib/constants/float64/pinf' );
27-
var EPS = require( '@stdlib/constants/float64/eps' );
28-
var abs = require( '@stdlib/math/base/special/abs' );
27+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2928
var erfc = require( './../lib' );
3029

3130

@@ -55,8 +54,6 @@ tape( 'main export is a function', function test( t ) {
5554

5655
tape( 'the function evaluates the complementary error function for `x` on the interval `[-5,-100]', function test( t ) {
5756
var expected;
58-
var delta;
59-
var tol;
6057
var x;
6158
var y;
6259
var i;
@@ -68,18 +65,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
6865
if ( y === expected[i] ) {
6966
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
7067
} else {
71-
delta = abs( y - expected[ i ] );
72-
tol = EPS * abs( expected[ i ] );
73-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
68+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
7469
}
7570
}
7671
t.end();
7772
});
7873

7974
tape( 'the function evaluates the complementary error function for `x` on the interval `[5,100]`', function test( t ) {
8075
var expected;
81-
var delta;
82-
var tol;
8376
var x;
8477
var y;
8578
var i;
@@ -91,18 +84,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
9184
if ( y === expected[i] ) {
9285
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
9386
} else {
94-
delta = abs( y - expected[ i ] );
95-
tol = EPS * abs( expected[ i ] );
96-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
87+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
9788
}
9889
}
9990
t.end();
10091
});
10192

10293
tape( 'the function evaluates the complementary error function for `x` on the interval `[-2.5,-28]`', function test( t ) {
10394
var expected;
104-
var delta;
105-
var tol;
10695
var x;
10796
var y;
10897
var i;
@@ -114,18 +103,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
114103
if ( y === expected[i] ) {
115104
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
116105
} else {
117-
delta = abs( y - expected[ i ] );
118-
tol = EPS * abs( expected[ i ] );
119-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
106+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
120107
}
121108
}
122109
t.end();
123110
});
124111

125112
tape( 'the function evaluates the complementary error function for `x` on the interval `[2.5,28]`', function test( t ) {
126113
var expected;
127-
var delta;
128-
var tol;
129114
var x;
130115
var y;
131116
var i;
@@ -137,18 +122,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
137122
if ( y === expected[i] ) {
138123
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
139124
} else {
140-
delta = abs( y - expected[ i ] );
141-
tol = EPS * abs( expected[ i ] );
142-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
125+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
143126
}
144127
}
145128
t.end();
146129
});
147130

148131
tape( 'the function evaluates the complementary error function for `x` on the interval `[-1,-3]`', function test( t ) {
149132
var expected;
150-
var delta;
151-
var tol;
152133
var x;
153134
var y;
154135
var i;
@@ -160,18 +141,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
160141
if ( y === expected[i] ) {
161142
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
162143
} else {
163-
delta = abs( y - expected[ i ] );
164-
tol = EPS * abs( expected[ i ] );
165-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
144+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
166145
}
167146
}
168147
t.end();
169148
});
170149

171150
tape( 'the function evaluates the complementary error function for `x` on the interval `[1,3]`', function test( t ) {
172151
var expected;
173-
var delta;
174-
var tol;
175152
var x;
176153
var y;
177154
var i;
@@ -183,18 +160,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
183160
if ( y === expected[i] ) {
184161
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
185162
} else {
186-
delta = abs( y - expected[ i ] );
187-
tol = EPS * abs( expected[ i ] );
188-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
163+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
189164
}
190165
}
191166
t.end();
192167
});
193168

194169
tape( 'the function evaluates the complementary error function for `x` on the interval `[-0.8,-1]`', function test( t ) {
195170
var expected;
196-
var delta;
197-
var tol;
198171
var x;
199172
var y;
200173
var i;
@@ -206,9 +179,7 @@ tape( 'the function evaluates the complementary error function for `x` on the in
206179
if ( y === expected[i] ) {
207180
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
208181
} else {
209-
delta = abs( y - expected[ i ] );
210-
tol = EPS * abs( expected[ i ] );
211-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
182+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
212183
}
213184
}
214185
t.end();

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

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var NINF = require( '@stdlib/constants/float64/ninf' );
2727
var PINF = require( '@stdlib/constants/float64/pinf' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
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

3231

3332
// FIXTURES //
@@ -64,8 +63,6 @@ tape( 'main export is a function', opts, function test( t ) {
6463

6564
tape( 'the function evaluates the complementary error function for `x` on the interval `[-5,-100]', opts, function test( t ) {
6665
var expected;
67-
var delta;
68-
var tol;
6966
var x;
7067
var y;
7168
var i;
@@ -77,18 +74,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
7774
if ( y === expected[i] ) {
7875
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
7976
} else {
80-
delta = abs( y - expected[ i ] );
81-
tol = 2.0 * EPS * abs( expected[ i ] );
82-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
77+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
8378
}
8479
}
8580
t.end();
8681
});
8782

8883
tape( 'the function evaluates the complementary error function for `x` on the interval `[5,100]`', opts, function test( t ) {
8984
var expected;
90-
var delta;
91-
var tol;
9285
var x;
9386
var y;
9487
var i;
@@ -100,18 +93,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
10093
if ( y === expected[i] ) {
10194
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
10295
} else {
103-
delta = abs( y - expected[ i ] );
104-
tol = 2.0 * EPS * abs( expected[ i ] );
105-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
96+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
10697
}
10798
}
10899
t.end();
109100
});
110101

111102
tape( 'the function evaluates the complementary error function for `x` on the interval `[-2.5,-28]`', opts, function test( t ) {
112103
var expected;
113-
var delta;
114-
var tol;
115104
var x;
116105
var y;
117106
var i;
@@ -123,18 +112,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
123112
if ( y === expected[i] ) {
124113
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
125114
} else {
126-
delta = abs( y - expected[ i ] );
127-
tol = 2.0 * EPS * abs( expected[ i ] );
128-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
115+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
129116
}
130117
}
131118
t.end();
132119
});
133120

134121
tape( 'the function evaluates the complementary error function for `x` on the interval `[2.5,28]`', opts, function test( t ) {
135122
var expected;
136-
var delta;
137-
var tol;
138123
var x;
139124
var y;
140125
var i;
@@ -146,18 +131,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
146131
if ( y === expected[i] ) {
147132
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
148133
} else {
149-
delta = abs( y - expected[ i ] );
150-
tol = 2.0 * EPS * abs( expected[ i ] );
151-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
134+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
152135
}
153136
}
154137
t.end();
155138
});
156139

157140
tape( 'the function evaluates the complementary error function for `x` on the interval `[-1,-3]`', opts, function test( t ) {
158141
var expected;
159-
var delta;
160-
var tol;
161142
var x;
162143
var y;
163144
var i;
@@ -169,18 +150,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
169150
if ( y === expected[i] ) {
170151
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
171152
} else {
172-
delta = abs( y - expected[ i ] );
173-
tol = 2.0 * EPS * abs( expected[ i ] );
174-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
153+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
175154
}
176155
}
177156
t.end();
178157
});
179158

180159
tape( 'the function evaluates the complementary error function for `x` on the interval `[1,3]`', opts, function test( t ) {
181160
var expected;
182-
var delta;
183-
var tol;
184161
var x;
185162
var y;
186163
var i;
@@ -192,18 +169,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
192169
if ( y === expected[i] ) {
193170
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
194171
} else {
195-
delta = abs( y - expected[ i ] );
196-
tol = 2.0 * EPS * abs( expected[ i ] );
197-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
172+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
198173
}
199174
}
200175
t.end();
201176
});
202177

203178
tape( 'the function evaluates the complementary error function for `x` on the interval `[-0.8,-1]`', opts, function test( t ) {
204179
var expected;
205-
var delta;
206-
var tol;
207180
var x;
208181
var y;
209182
var i;
@@ -215,18 +188,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
215188
if ( y === expected[i] ) {
216189
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
217190
} else {
218-
delta = abs( y - expected[ i ] );
219-
tol = 2.0 * EPS * abs( expected[ i ] );
220-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
191+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
221192
}
222193
}
223194
t.end();
224195
});
225196

226197
tape( 'the function evaluates the complementary error function for `x` on the interval `[0.8,1]`', opts, function test( t ) {
227198
var expected;
228-
var delta;
229-
var tol;
230199
var x;
231200
var y;
232201
var i;
@@ -238,18 +207,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
238207
if ( y === expected[i] ) {
239208
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
240209
} else {
241-
delta = abs( y - expected[ i ] );
242-
tol = 2.0 * EPS * abs( expected[ i ] );
243-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
210+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
244211
}
245212
}
246213
t.end();
247214
});
248215

249216
tape( 'the function evaluates the complementary error function for `x` on the interval `[-0.8,0.8]`', opts, function test( t ) {
250217
var expected;
251-
var delta;
252-
var tol;
253218
var x;
254219
var y;
255220
var i;
@@ -261,18 +226,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
261226
if ( y === expected[i] ) {
262227
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
263228
} else {
264-
delta = abs( y - expected[ i ] );
265-
tol = 2.0 * EPS * abs( expected[ i ] );
266-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
229+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
267230
}
268231
}
269232
t.end();
270233
});
271234

272235
tape( 'the function evaluates the complementary error function for `x` on the interval `[-1e-300,-1e-308]`', opts, function test( t ) {
273236
var expected;
274-
var delta;
275-
var tol;
276237
var x;
277238
var y;
278239
var i;
@@ -284,18 +245,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
284245
if ( y === expected[i] ) {
285246
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
286247
} else {
287-
delta = abs( y - expected[ i ] );
288-
tol = 1.0 * EPS * abs( expected[ i ] );
289-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
248+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
290249
}
291250
}
292251
t.end();
293252
});
294253

295254
tape( 'the function evaluates the complementary error function for `x` on the interval `[1e-300,1e-308]`', opts, function test( t ) {
296255
var expected;
297-
var delta;
298-
var tol;
299256
var x;
300257
var y;
301258
var i;
@@ -307,18 +264,14 @@ tape( 'the function evaluates the complementary error function for `x` on the in
307264
if ( y === expected[i] ) {
308265
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
309266
} else {
310-
delta = abs( y - expected[ i ] );
311-
tol = 1.0 * EPS * abs( expected[ i ] );
312-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
267+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
313268
}
314269
}
315270
t.end();
316271
});
317272

318273
tape( 'the function evaluates the complementary error function for subnormal `x`', opts, function test( t ) {
319274
var expected;
320-
var delta;
321-
var tol;
322275
var x;
323276
var y;
324277
var i;
@@ -330,9 +283,7 @@ tape( 'the function evaluates the complementary error function for subnormal `x`
330283
if ( y === expected[i] ) {
331284
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
332285
} else {
333-
delta = abs( y - expected[ i ] );
334-
tol = 1.0 * EPS * abs( expected[ i ] );
335-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
286+
t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' );
336287
}
337288
}
338289
t.end();

0 commit comments

Comments
 (0)