23
23
var tape = require ( 'tape' ) ;
24
24
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
25
25
var EPS = require ( '@stdlib/constants/float64/eps' ) ;
26
+ var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
26
27
var abs = require ( '@stdlib/math/base/special/abs' ) ;
27
28
var cscd = require ( './../lib' ) ;
28
29
@@ -43,7 +44,7 @@ tape( 'main export is a function', function test( t ) {
43
44
44
45
tape ( 'the function returns `NaN` if provided `NaN`' , function test ( t ) {
45
46
var v = cscd ( NaN ) ;
46
- t . equal ( isnan ( v ) , true , 'returns NaN ' ) ;
47
+ t . equal ( isnan ( v ) , true , 'returns expected value ' ) ;
47
48
t . end ( ) ;
48
49
} ) ;
49
50
@@ -60,11 +61,15 @@ tape( 'the function computes the cosecant in degrees (negative values)', functio
60
61
61
62
for ( i = 0 ; i < x . length ; i ++ ) {
62
63
y = cscd ( x [ i ] ) ;
64
+ if ( expected [ i ] === null ) {
65
+ t . equal ( y , PINF , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
66
+ continue ;
67
+ }
63
68
if ( y === expected [ i ] ) {
64
69
t . equal ( y , expected [ i ] , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
65
70
} else {
66
71
delta = abs ( y - expected [ i ] ) ;
67
- tol = 1.4 * EPS * abs ( expected [ i ] ) ;
72
+ tol = 1.3 * EPS * abs ( expected [ i ] ) ;
68
73
t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
69
74
}
70
75
}
@@ -84,11 +89,15 @@ tape( 'the function computes the cosecant in degrees (positive values)', functio
84
89
85
90
for ( i = 0 ; i < x . length ; i ++ ) {
86
91
y = cscd ( x [ i ] ) ;
92
+ if ( expected [ i ] === null ) {
93
+ t . equal ( y , PINF , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
94
+ continue ;
95
+ }
87
96
if ( y === expected [ i ] ) {
88
97
t . equal ( y , expected [ i ] , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
89
98
} else {
90
99
delta = abs ( y - expected [ i ] ) ;
91
- tol = 1.4 * EPS * abs ( expected [ i ] ) ;
100
+ tol = 1.3 * EPS * abs ( expected [ i ] ) ;
92
101
t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
93
102
}
94
103
}
0 commit comments