2323var resolve = require ( 'path' ) . resolve ;
2424var tape = require ( 'tape' ) ;
2525var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
26- var abs = require ( '@stdlib/math/base/special/abs' ) ;
2726var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
2827var NINF = require ( '@stdlib/constants/float64/ninf' ) ;
29- var EPS = require ( '@stdlib/constants/float64/eps ' ) ;
28+ var isAlmostSameValue = require ( '@stdlib/assert/is-almost-same-value ' ) ;
3029var tryRequire = require ( '@stdlib/utils/try-require' ) ;
3130
3231
@@ -58,8 +57,6 @@ tape( 'main export is a function', opts, function test( t ) {
5857
5958tape ( 'the function computes the cosine (medium negative values)' , opts , function test ( t ) {
6059 var expected ;
61- var delta ;
62- var tol ;
6360 var x ;
6461 var y ;
6562 var i ;
@@ -69,22 +66,14 @@ tape( 'the function computes the cosine (medium negative values)', opts, functio
6966
7067 for ( i = 0 ; i < x . length ; i ++ ) {
7168 y = cos ( x [ i ] ) ;
72- if ( y === expected [ i ] ) {
73- t . strictEqual ( y , expected [ i ] , 'x: ' + x [ i ] + '. Expected: ' + expected [ i ] ) ;
74- } else {
75- delta = abs ( y - expected [ i ] ) ;
76- tol = EPS * abs ( expected [ i ] ) ;
77- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
78- }
69+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 1 ) , true , 'returns expected value' ) ;
7970 }
8071
8172 t . end ( ) ;
8273} ) ;
8374
8475tape ( 'the function computes the cosine (positive medium values)' , opts , function test ( t ) {
8576 var expected ;
86- var delta ;
87- var tol ;
8877 var x ;
8978 var y ;
9079 var i ;
@@ -94,22 +83,14 @@ tape( 'the function computes the cosine (positive medium values)', opts, functio
9483
9584 for ( i = 0 ; i < x . length ; i ++ ) {
9685 y = cos ( x [ i ] ) ;
97- if ( y === expected [ i ] ) {
98- t . strictEqual ( y , expected [ i ] , 'x: ' + x [ i ] + '. Expected: ' + expected [ i ] ) ;
99- } else {
100- delta = abs ( y - expected [ i ] ) ;
101- tol = EPS * abs ( expected [ i ] ) ;
102- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
103- }
86+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 1 ) , true , 'returns expected value' ) ;
10487 }
10588
10689 t . end ( ) ;
10790} ) ;
10891
10992tape ( 'the function computes the cosine (large negative values)' , opts , function test ( t ) {
11093 var expected ;
111- var delta ;
112- var tol ;
11394 var x ;
11495 var y ;
11596 var i ;
@@ -119,22 +100,14 @@ tape( 'the function computes the cosine (large negative values)', opts, function
119100
120101 for ( i = 0 ; i < x . length ; i ++ ) {
121102 y = cos ( x [ i ] ) ;
122- if ( y === expected [ i ] ) {
123- t . strictEqual ( y , expected [ i ] , 'x: ' + x [ i ] + '. Expected: ' + expected [ i ] ) ;
124- } else {
125- delta = abs ( y - expected [ i ] ) ;
126- tol = EPS * abs ( expected [ i ] ) ;
127- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
128- }
103+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 1 ) , true , 'returns expected value' ) ;
129104 }
130105
131106 t . end ( ) ;
132107} ) ;
133108
134109tape ( 'the function computes the cosine (large positive values)' , opts , function test ( t ) {
135110 var expected ;
136- var delta ;
137- var tol ;
138111 var x ;
139112 var y ;
140113 var i ;
@@ -144,22 +117,14 @@ tape( 'the function computes the cosine (large positive values)', opts, function
144117
145118 for ( i = 0 ; i < x . length ; i ++ ) {
146119 y = cos ( x [ i ] ) ;
147- if ( y === expected [ i ] ) {
148- t . strictEqual ( y , expected [ i ] , 'x: ' + x [ i ] + '. Expected: ' + expected [ i ] ) ;
149- } else {
150- delta = abs ( y - expected [ i ] ) ;
151- tol = EPS * abs ( expected [ i ] ) ;
152- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
153- }
120+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 1 ) , true , 'returns expected value' ) ;
154121 }
155122
156123 t . end ( ) ;
157124} ) ;
158125
159126tape ( 'the function computes the cosine (huge negative values)' , opts , function test ( t ) {
160127 var expected ;
161- var delta ;
162- var tol ;
163128 var x ;
164129 var y ;
165130 var i ;
@@ -169,22 +134,13 @@ tape( 'the function computes the cosine (huge negative values)', opts, function
169134
170135 for ( i = 0 ; i < x . length ; i ++ ) {
171136 y = cos ( x [ i ] ) ;
172- if ( y === expected [ i ] ) {
173- t . strictEqual ( y , expected [ i ] , 'x: ' + x [ i ] + '. Expected: ' + expected [ i ] ) ;
174- } else {
175- delta = abs ( y - expected [ i ] ) ;
176- tol = EPS * abs ( expected [ i ] ) ;
177- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
178- }
137+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 1 ) , true , 'returns expected value' ) ;
179138 }
180-
181139 t . end ( ) ;
182140} ) ;
183141
184142tape ( 'the function computes the cosine (huge positive values)' , opts , function test ( t ) {
185143 var expected ;
186- var delta ;
187- var tol ;
188144 var x ;
189145 var y ;
190146 var i ;
@@ -194,13 +150,7 @@ tape( 'the function computes the cosine (huge positive values)', opts, function
194150
195151 for ( i = 0 ; i < x . length ; i ++ ) {
196152 y = cos ( x [ i ] ) ;
197- if ( y === expected [ i ] ) {
198- t . strictEqual ( y , expected [ i ] , 'x: ' + x [ i ] + '. Expected: ' + expected [ i ] ) ;
199- } else {
200- delta = abs ( y - expected [ i ] ) ;
201- tol = EPS * abs ( expected [ i ] ) ;
202- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
203- }
153+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 1 ) , true , 'returns expected value' ) ;
204154 }
205155
206156 t . end ( ) ;
0 commit comments