@@ -130,6 +130,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
130
130
t . end ( ) ;
131
131
} ) ;
132
132
133
+ tape ( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessor)' , function test ( t ) {
134
+ var x ;
135
+ var v ;
136
+
137
+ x = toAccessorArray ( [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ) ;
138
+
139
+ v = varianceyc ( 0 , 1 , x , 1 , 0 ) ;
140
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
141
+
142
+ v = varianceyc ( - 1 , 1 , x , 1 , 0 ) ;
143
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
144
+
145
+ t . end ( ) ;
146
+ } ) ;
147
+
133
148
tape ( 'if provided an `N` parameter equal to `1`, the function returns a population variance of `0`' , function test ( t ) {
134
149
var x ;
135
150
var v ;
@@ -142,6 +157,18 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
142
157
t . end ( ) ;
143
158
} ) ;
144
159
160
+ tape ( 'if provided an `N` parameter equal to `1`, the function returns a population variance of `0` (accessor)' , function test ( t ) {
161
+ var x ;
162
+ var v ;
163
+
164
+ x = toAccessorArray ( [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ) ;
165
+
166
+ v = varianceyc ( 1 , 0 , x , 1 , 0 ) ;
167
+ t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
168
+
169
+ t . end ( ) ;
170
+ } ) ;
171
+
145
172
tape ( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN`' , function test ( t ) {
146
173
var x ;
147
174
var v ;
@@ -157,6 +184,21 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
157
184
t . end ( ) ;
158
185
} ) ;
159
186
187
+ tape ( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN (accessor)`' , function test ( t ) {
188
+ var x ;
189
+ var v ;
190
+
191
+ x = toAccessorArray ( [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ) ;
192
+
193
+ v = varianceyc ( x . length , x . length , x , 1 , 0 ) ;
194
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
195
+
196
+ v = varianceyc ( x . length , x . length + 1 , x , 1 , 0 ) ;
197
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
198
+
199
+ t . end ( ) ;
200
+ } ) ;
201
+
160
202
tape ( 'the function supports a `stride` parameter' , function test ( t ) {
161
203
var x ;
162
204
var v ;
0 commit comments