@@ -25,8 +25,7 @@ var tape = require( 'tape' );
2525var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2626var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
2727var 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' ) ;
3029var tryRequire = require ( '@stdlib/utils/try-require' ) ;
3130
3231
@@ -55,8 +54,6 @@ tape( 'main export is a function', opts, function test( t ) {
5554
5655tape ( 'the function computes the hyperbolic cosine' , opts , 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
8071tape ( 'the function computes the hyperbolic cosine (tiny values)' , opts , 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
10487tape ( 'the function computes the hyperbolic cosine (large values)' , opts , function test ( t ) {
10588 var expected ;
106- var delta ;
107- var tol ;
10889 var x ;
10990 var y ;
11091 var i ;
@@ -114,13 +95,7 @@ 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} ) ;
0 commit comments