Skip to content

Commit f12759c

Browse files
committed
test: migrate 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 5bde225 commit f12759c

File tree

2 files changed

+23
-61
lines changed

2 files changed

+23
-61
lines changed

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

Lines changed: 4 additions & 29 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 PINF = require( '@stdlib/constants/float64/pinf' );
2626
var NINF = require( '@stdlib/constants/float64/ninf' );
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 cosh = require( './../lib' );
3029

3130

@@ -46,8 +45,6 @@ tape( 'main export is a function', function test( t ) {
4645

4746
tape( 'the function computes the hyperbolic cosine', function test( t ) {
4847
var expected;
49-
var delta;
50-
var tol;
5148
var x;
5249
var y;
5350
var i;
@@ -57,21 +54,13 @@ tape( 'the function computes the hyperbolic cosine', function test( t ) {
5754

5855
for ( i = 0; i < x.length; i++ ) {
5956
y = cosh( x[i] );
60-
if ( y === expected[ i ] ) {
61-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
62-
} else {
63-
delta = abs( y - expected[i] );
64-
tol = EPS * abs( expected[i] );
65-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
66-
}
57+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
6758
}
6859
t.end();
6960
});
7061

7162
tape( 'the function computes the hyperbolic cosine (tiny values)', function test( t ) {
7263
var expected;
73-
var delta;
74-
var tol;
7564
var x;
7665
var y;
7766
var i;
@@ -81,21 +70,13 @@ tape( 'the function computes the hyperbolic cosine (tiny values)', function test
8170

8271
for ( i = 0; i < x.length; i++ ) {
8372
y = cosh( x[i] );
84-
if ( y === expected[ i ] ) {
85-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
86-
} else {
87-
delta = abs( y - expected[i] );
88-
tol = EPS * abs( expected[i] );
89-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
90-
}
73+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
9174
}
9275
t.end();
9376
});
9477

9578
tape( 'the function computes the hyperbolic cosine (large values)', function test( t ) {
9679
var expected;
97-
var delta;
98-
var tol;
9980
var x;
10081
var y;
10182
var i;
@@ -105,13 +86,7 @@ tape( 'the function computes the hyperbolic cosine (large values)', function tes
10586

10687
for ( i = 0; i < x.length; i++ ) {
10788
y = cosh( x[i] );
108-
if ( y === expected[ i ] ) {
109-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
110-
} else {
111-
delta = abs( y - expected[i] );
112-
tol = EPS * abs( expected[i] );
113-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
114-
}
89+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
11590
}
11691
t.end();
11792
});

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

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ var tape = require( 'tape' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var PINF = require( '@stdlib/constants/float64/pinf' );
2727
var NINF = require( '@stdlib/constants/float64/ninf' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
29-
var abs = require( '@stdlib/math/base/special/abs' );
28+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
3029
var tryRequire = require( '@stdlib/utils/try-require' );
3130

3231

@@ -53,10 +52,8 @@ tape( 'main export is a function', opts, function test( t ) {
5352
t.end();
5453
});
5554

56-
tape( 'the function computes the hyperbolic cosine', opts, function test( t ) {
55+
tape( 'the function computes the hyperbolic cosine', function test( t ) {
5756
var expected;
58-
var delta;
59-
var tol;
6057
var x;
6158
var y;
6259
var i;
@@ -66,21 +63,13 @@ tape( 'the function computes the hyperbolic cosine', opts, function test( t ) {
6663

6764
for ( i = 0; i < x.length; i++ ) {
6865
y = cosh( x[i] );
69-
if ( y === expected[ i ] ) {
70-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
71-
} else {
72-
delta = abs( y - expected[i] );
73-
tol = EPS * abs( expected[i] );
74-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
75-
}
66+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
7667
}
7768
t.end();
7869
});
7970

80-
tape( 'the function computes the hyperbolic cosine (tiny values)', opts, function test( t ) {
71+
tape( 'the function computes the hyperbolic cosine (tiny values)', function test( t ) {
8172
var expected;
82-
var delta;
83-
var tol;
8473
var x;
8574
var y;
8675
var i;
@@ -90,21 +79,13 @@ tape( 'the function computes the hyperbolic cosine (tiny values)', opts, functio
9079

9180
for ( i = 0; i < x.length; i++ ) {
9281
y = cosh( x[i] );
93-
if ( y === expected[ i ] ) {
94-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+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]+'. Value: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
99-
}
82+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
10083
}
10184
t.end();
10285
});
10386

104-
tape( 'the function computes the hyperbolic cosine (large values)', opts, function test( t ) {
87+
tape( 'the function computes the hyperbolic cosine (large values)', function test( t ) {
10588
var expected;
106-
var delta;
107-
var tol;
10889
var x;
10990
var y;
11091
var i;
@@ -114,17 +95,23 @@ tape( 'the function computes the hyperbolic cosine (large values)', opts, functi
11495

11596
for ( i = 0; i < x.length; i++ ) {
11697
y = cosh( x[i] );
117-
if ( y === expected[ i ] ) {
118-
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
119-
} else {
120-
delta = abs( y - expected[i] );
121-
tol = EPS * abs( expected[i] );
122-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
123-
}
98+
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
12499
}
125100
t.end();
126101
});
127102

103+
tape( 'the function returns `1` if provided `+-0`', function test( t ) {
104+
var v;
105+
106+
v = cosh( -0.0 );
107+
t.strictEqual( v, 1.0, 'returns expected value' );
108+
109+
v = cosh( +0.0 );
110+
t.strictEqual( v, 1.0, 'returns expected value' );
111+
112+
t.end();
113+
});
114+
128115
tape( 'the function returns `1` if provided `+-0`', opts, function test( t ) {
129116
var v;
130117

0 commit comments

Comments
 (0)