@@ -39,12 +39,10 @@ var zrot = require( './../lib/zrot.js' );
39
39
* @param {Collection } actual - actual values
40
40
* @param {Collection } expected - expected values
41
41
* @param {number } rtol - relative tolerance
42
- * @param {number } atol - absolute tolerance
43
42
*/
44
- function isApprox ( t , actual , expected , rtol , atol ) {
45
- var absTol ;
46
- var relTol ;
43
+ function isApprox ( t , actual , expected , rtol ) {
47
44
var delta ;
45
+ var tol ;
48
46
var i ;
49
47
50
48
t . strictEqual ( actual . length , expected . length , 'returns expected value' ) ;
@@ -53,9 +51,11 @@ function isApprox( t, actual, expected, rtol, atol ) {
53
51
t . strictEqual ( actual [ i ] , expected [ i ] , 'returns expected value' ) ;
54
52
} else {
55
53
delta = abs ( actual [ i ] - expected [ i ] ) ;
56
- relTol = rtol * EPS * abs ( expected [ i ] ) ;
57
- absTol = atol * EPS ;
58
- t . ok ( delta <= relTol || delta < absTol , 'within tolerance. actual: ' + actual [ i ] + '. expected: ' + expected [ i ] + '. delta: ' + delta + '. relative tol: ' + relTol + '. absolute tol: ' + absTol + '.' ) ;
54
+ tol = rtol * EPS * abs ( expected [ i ] ) ;
55
+ if ( tol === 0.0 ) {
56
+ tol = EPS ; // absolute tolerance when `expected[i]` is `0`
57
+ }
58
+ t . ok ( delta <= tol , 'within tolerance. actual: ' + actual [ i ] + '. expected: ' + expected [ i ] + '. delta: ' + delta + '. tol: ' + tol + '.' ) ;
59
59
}
60
60
}
61
61
}
@@ -133,8 +133,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
133
133
] ) ;
134
134
135
135
out = zrot ( cx . length , cx , 1 , cy , 1 , 0.8 , s ) ;
136
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
137
- isApprox ( t , viewY , cye , 2.0 , 0.0 ) ;
136
+ isApprox ( t , viewX , cxe , 2.0 ) ;
137
+ isApprox ( t , viewY , cye , 2.0 ) ;
138
138
t . strictEqual ( out , cy , 'returns expected value' ) ;
139
139
t . end ( ) ;
140
140
} ) ;
@@ -198,8 +198,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
198
198
] ) ;
199
199
200
200
out = zrot ( cx . length , cx , 1 , cy , 1 , 1.25 , s ) ;
201
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
202
- isApprox ( t , viewY , cye , 2.0 , 0.0 ) ;
201
+ isApprox ( t , viewX , cxe , 2.0 ) ;
202
+ isApprox ( t , viewY , cye , 2.0 ) ;
203
203
t . strictEqual ( out , cy , 'returns expected value' ) ;
204
204
t . end ( ) ;
205
205
} ) ;
@@ -263,8 +263,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
263
263
] ) ;
264
264
265
265
out = zrot ( cx . length , cx , 1 , cy , 1 , 1.25 , s ) ;
266
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
267
- isApprox ( t , viewY , cye , 4.0 , 2.0 ) ;
266
+ isApprox ( t , viewX , cxe , 2.0 ) ;
267
+ isApprox ( t , viewY , cye , 4.0 ) ;
268
268
t . strictEqual ( out , cy , 'returns expected value' ) ;
269
269
t . end ( ) ;
270
270
} ) ;
@@ -326,8 +326,8 @@ tape( 'the function supports an `x` stride', function test( t ) {
326
326
] ) ;
327
327
328
328
out = zrot ( 2 , cx , 2 , cy , 1 , 0.8 , s ) ;
329
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
330
- isApprox ( t , viewY , cye , 4.0 , 0.0 ) ;
329
+ isApprox ( t , viewX , cxe , 2.0 ) ;
330
+ isApprox ( t , viewY , cye , 4.0 ) ;
331
331
t . strictEqual ( out , cy , 'returns expected value' ) ;
332
332
t . end ( ) ;
333
333
} ) ;
@@ -389,8 +389,8 @@ tape( 'the function supports a `y` stride', function test( t ) {
389
389
] ) ;
390
390
391
391
out = zrot ( 2 , cx , 1 , cy , 2 , 0.8 , s ) ;
392
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
393
- isApprox ( t , viewY , cye , 2.0 , 2.0 ) ;
392
+ isApprox ( t , viewX , cxe , 2.0 ) ;
393
+ isApprox ( t , viewY , cye , 2.0 ) ;
394
394
t . strictEqual ( out , cy , 'returns expected value' ) ;
395
395
t . end ( ) ;
396
396
} ) ;
@@ -498,8 +498,8 @@ tape( 'the function supports negative strides', function test( t ) {
498
498
] ) ;
499
499
500
500
out = zrot ( 2 , cx , - 1 , cy , - 2 , 0.8 , s ) ;
501
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
502
- isApprox ( t , viewY , cye , 2.0 , 2.0 ) ;
501
+ isApprox ( t , viewX , cxe , 2.0 ) ;
502
+ isApprox ( t , viewY , cye , 2.0 ) ;
503
503
t . strictEqual ( out , cy , 'returns expected value' ) ;
504
504
t . end ( ) ;
505
505
} ) ;
@@ -561,8 +561,8 @@ tape( 'the function supports complex access patterns', function test( t ) {
561
561
] ) ;
562
562
563
563
out = zrot ( 2 , cx , 2 , cy , - 1 , 0.8 , s ) ;
564
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
565
- isApprox ( t , viewY , cye , 4.0 , 0.0 ) ;
564
+ isApprox ( t , viewX , cxe , 2.0 ) ;
565
+ isApprox ( t , viewY , cye , 4.0 ) ;
566
566
t . strictEqual ( out , cy , 'returns expected value' ) ;
567
567
t . end ( ) ;
568
568
} ) ;
@@ -632,8 +632,8 @@ tape( 'the function supports view offsets', function test( t ) {
632
632
] ) ;
633
633
634
634
out = zrot ( 2 , cx1 , - 2 , cy1 , 1 , 0.8 , s ) ;
635
- isApprox ( t , viewX , cxe , 2.0 , 0.0 ) ;
636
- isApprox ( t , viewY , cye , 2.0 , 2 .0 ) ;
635
+ isApprox ( t , viewX , cxe , 2.0 ) ;
636
+ isApprox ( t , viewY , cye , 4 .0 ) ;
637
637
t . strictEqual ( out , cy1 , 'returns expected value' ) ;
638
638
t . end ( ) ;
639
639
} ) ;
0 commit comments