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 half-value versed sine (for -256*pi < x < 0 )' , 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,16 @@ tape( 'the function computes the half-value versed sine (for -256*pi < x < 0 )',
6966
7067 for ( i = 0 ; i < x . length ; i ++ ) {
7168 y = haversin ( 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 = 1.7 * EPS * abs ( expected [ i ] ) ;
77- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. Expected: ' + expected [ i ] + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
78- }
69+
70+ // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
71+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 2 ) , true , 'returns expected value' ) ;
7972 }
8073
8174 t . end ( ) ;
8275} ) ;
8376
8477tape ( 'the function computes the half-value versed sine (for 0 < x < 256*pi )' , opts , function test ( t ) {
8578 var expected ;
86- var delta ;
87- var tol ;
8879 var x ;
8980 var y ;
9081 var i ;
@@ -94,22 +85,16 @@ tape( 'the function computes the half-value versed sine (for 0 < x < 256*pi )',
9485
9586 for ( i = 0 ; i < x . length ; i ++ ) {
9687 y = haversin ( 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 = 1.7 * EPS * abs ( expected [ i ] ) ;
102- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. Expected: ' + expected [ i ] + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
103- }
88+
89+ // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
90+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 2 ) , true , 'returns expected value' ) ;
10491 }
10592
10693 t . end ( ) ;
10794} ) ;
10895
10996tape ( 'the function computes the half-value versed sine (for -2**60 (pi/2) < x < -2**20 (pi/2) )' , opts , function test ( t ) {
11097 var expected ;
111- var delta ;
112- var tol ;
11398 var x ;
11499 var y ;
115100 var i ;
@@ -119,22 +104,16 @@ tape( 'the function computes the half-value versed sine (for -2**60 (pi/2) < x <
119104
120105 for ( i = 0 ; i < x . length ; i ++ ) {
121106 y = haversin ( 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 = 1.7 * EPS * abs ( expected [ i ] ) ;
127- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. Expected: ' + expected [ i ] + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
128- }
107+
108+ // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
109+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 2 ) , true , 'returns expected value' ) ;
129110 }
130111
131112 t . end ( ) ;
132113} ) ;
133114
134115tape ( 'the function computes the half-value versed sine (for 2**20 (pi/2) < x < 2**60 (pi/2) )' , opts , function test ( t ) {
135116 var expected ;
136- var delta ;
137- var tol ;
138117 var x ;
139118 var y ;
140119 var i ;
@@ -144,22 +123,16 @@ tape( 'the function computes the half-value versed sine (for 2**20 (pi/2) < x <
144123
145124 for ( i = 0 ; i < x . length ; i ++ ) {
146125 y = haversin ( 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 = 1.7 * EPS * abs ( expected [ i ] ) ;
152- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. Expected: ' + expected [ i ] + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
153- }
126+
127+ // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
128+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 2 ) , true , 'returns expected value' ) ;
154129 }
155130
156131 t . end ( ) ;
157132} ) ;
158133
159134tape ( 'the function computes the half-value versed sine (for x <= -2**60 (PI/2) )' , opts , function test ( t ) {
160135 var expected ;
161- var delta ;
162- var tol ;
163136 var x ;
164137 var y ;
165138 var i ;
@@ -169,22 +142,16 @@ tape( 'the function computes the half-value versed sine (for x <= -2**60 (PI/2)
169142
170143 for ( i = 0 ; i < x . length ; i ++ ) {
171144 y = haversin ( 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 = 1.7 * EPS * abs ( expected [ i ] ) ;
177- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. Expected: ' + expected [ i ] + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
178- }
145+
146+ // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
147+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 2 ) , true , 'returns expected value' ) ;
179148 }
180149
181150 t . end ( ) ;
182151} ) ;
183152
184153tape ( 'the function computes the half-value versed sine (for x >= 2**60 (PI/2) )' , opts , function test ( t ) {
185154 var expected ;
186- var delta ;
187- var tol ;
188155 var x ;
189156 var y ;
190157 var i ;
@@ -194,13 +161,9 @@ tape( 'the function computes the half-value versed sine (for x >= 2**60 (PI/2) )
194161
195162 for ( i = 0 ; i < x . length ; i ++ ) {
196163 y = haversin ( 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 = 1.7 * EPS * abs ( expected [ i ] ) ;
202- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. Expected: ' + expected [ i ] + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
203- }
164+
165+ // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
166+ t . strictEqual ( isAlmostSameValue ( y , expected [ i ] , 2 ) , true , 'returns expected value' ) ;
204167 }
205168
206169 t . end ( ) ;
0 commit comments