22
22
23
23
var tape = require ( 'tape' ) ;
24
24
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
25
- var randu = require ( '@stdlib/random/base/randu ' ) ;
25
+ var uniform = require ( '@stdlib/random/base/uniform ' ) ;
26
26
var abs = require ( '@stdlib/math/base/special/abs' ) ;
27
27
var EPS = require ( '@stdlib/constants/float64/eps' ) ;
28
28
var asind = require ( './../lib' ) ;
@@ -54,13 +54,13 @@ tape( 'the function computes the arcsine in degrees (negative values)', function
54
54
expected = negative . expected ;
55
55
56
56
for ( i = 0 ; i < x . length ; i ++ ) {
57
- y = asind ( x [ i ] ) ;
57
+ y = asind ( x [ i ] ) ;
58
58
if ( y === expected [ i ] ) {
59
- t . equal ( y , expected [ i ] , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
59
+ t . equal ( y , expected [ i ] , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
60
60
} else {
61
- delta = abs ( y - expected [ i ] ) ;
62
- tol = 1.4 * EPS * abs ( expected [ i ] ) ;
63
- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
61
+ delta = abs ( y - expected [ i ] ) ;
62
+ tol = 1.2 * EPS * abs ( expected [ i ] ) ;
63
+ t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
64
64
}
65
65
}
66
66
t . end ( ) ;
@@ -78,21 +78,21 @@ tape( 'the function computes the arcsine in degrees (positive values)', function
78
78
expected = positive . expected ;
79
79
80
80
for ( i = 0 ; i < x . length ; i ++ ) {
81
- y = asind ( x [ i ] ) ;
81
+ y = asind ( x [ i ] ) ;
82
82
if ( y === expected [ i ] ) {
83
- t . equal ( y , expected [ i ] , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
83
+ t . equal ( y , expected [ i ] , 'x: ' + x [ i ] + '. E: ' + expected [ i ] ) ;
84
84
} else {
85
- delta = abs ( y - expected [ i ] ) ;
86
- tol = 1.4 * EPS * abs ( expected [ i ] ) ;
87
- t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
85
+ delta = abs ( y - expected [ i ] ) ;
86
+ tol = 1.2 * EPS * abs ( expected [ i ] ) ;
87
+ t . ok ( delta <= tol , 'within tolerance. x: ' + x [ i ] + '. y: ' + y + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
88
88
}
89
89
}
90
90
t . end ( ) ;
91
91
} ) ;
92
92
93
93
tape ( 'the function returns `NaN` if provided `NaN`' , function test ( t ) {
94
94
var v = asind ( NaN ) ;
95
- t . equal ( isnan ( v ) , true , 'returns NaN ' ) ;
95
+ t . equal ( isnan ( v ) , true , 'returns expected value ' ) ;
96
96
t . end ( ) ;
97
97
} ) ;
98
98
@@ -101,8 +101,8 @@ tape( 'the function returns `NaN` if provided a value less than `-1`', function
101
101
var i ;
102
102
103
103
for ( i = 0 ; i < 1e3 ; i ++ ) {
104
- v = - ( randu ( ) * 1.0e6 ) - ( 1.0 - EPS ) ;
105
- t . equal ( isnan ( asind ( v ) ) , true , 'returns NaN when provided ' + v ) ;
104
+ v = uniform ( - 1.0e6 , - 1.0 - EPS ) ;
105
+ t . equal ( isnan ( asind ( v ) ) , true , 'returns expected value when provided ' + v ) ;
106
106
}
107
107
t . end ( ) ;
108
108
} ) ;
@@ -112,8 +112,8 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi
112
112
var i ;
113
113
114
114
for ( i = 0 ; i < 1e3 ; i ++ ) {
115
- v = ( randu ( ) * 1.0e6 ) + 1.0 + EPS ;
116
- t . equal ( isnan ( asind ( v ) ) , true , 'returns NaN when provided ' + v ) ;
115
+ v = uniform ( 1.0 + EPS , 1.0e6 ) ;
116
+ t . equal ( isnan ( asind ( v ) ) , true , 'returns expected value when provided ' + v ) ;
117
117
}
118
118
t . end ( ) ;
119
119
} ) ;
0 commit comments