@@ -39,7 +39,7 @@ tape( 'the function has an arity of 5', function test( t ) {
3939 t . end ( ) ;
4040} ) ;
4141
42- tape ( 'the function calculates the population variance of a strided array (ignoring `NaN` values) ' , function test ( t ) {
42+ tape ( 'the function calculates the population variance of a strided array' , function test ( t ) {
4343 var x ;
4444 var v ;
4545 var i ;
@@ -93,7 +93,7 @@ tape( 'the function calculates the population variance of a strided array (ignor
9393 t . end ( ) ;
9494} ) ;
9595
96- tape ( 'the function calculates the population variance of a strided array (ignoring `NaN` values) ( accessors)' , function test ( t ) {
96+ tape ( 'the function calculates the population variance of a strided array (accessors)' , function test ( t ) {
9797 var x ;
9898 var v ;
9999 var i ;
@@ -147,7 +147,7 @@ tape( 'the function calculates the population variance of a strided array (ignor
147147 t . end ( ) ;
148148} ) ;
149149
150- tape ( 'the function calculates the sample variance of a strided array (ignoring `NaN` values) ' , function test ( t ) {
150+ tape ( 'the function calculates the sample variance of a strided array' , function test ( t ) {
151151 var x ;
152152 var v ;
153153 var i ;
@@ -201,7 +201,7 @@ tape( 'the function calculates the sample variance of a strided array (ignoring
201201 t . end ( ) ;
202202} ) ;
203203
204- tape ( 'the function calculates the sample variance of a strided array (ignoring `NaN` values) ( accessors)' , function test ( t ) {
204+ tape ( 'the function calculates the sample variance of a strided array (accessors)' , function test ( t ) {
205205 var x ;
206206 var v ;
207207 var i ;
@@ -270,6 +270,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
270270 t . end ( ) ;
271271} ) ;
272272
273+ tape ( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)' , function test ( t ) {
274+ var x ;
275+ var v ;
276+
277+ x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
278+
279+ v = nanvariancewd ( 0 , 1 , toAccessorArray ( x ) , 1 , 0 ) ;
280+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
281+
282+ v = nanvariancewd ( - 1 , 1 , toAccessorArray ( x ) , 1 , 0 ) ;
283+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
284+
285+ t . end ( ) ;
286+ } ) ;
287+
273288tape ( 'if provided an `N` parameter equal to `1`, the function returns a population variance of `0` provided the first element is not `NaN`' , function test ( t ) {
274289 var x ;
275290 var v ;
@@ -287,6 +302,23 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
287302 t . end ( ) ;
288303} ) ;
289304
305+ tape ( 'if provided an `N` parameter equal to `1`, the function returns a population variance of `0` provided the first element is not `NaN` (accessors)' , function test ( t ) {
306+ var x ;
307+ var v ;
308+
309+ x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
310+
311+ v = nanvariancewd ( 1 , 0 , toAccessorArray ( x ) , 1 , 0 ) ;
312+ t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
313+
314+ x = [ NaN , 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
315+
316+ v = nanvariancewd ( 1 , 0 , toAccessorArray ( x ) , 1 , 0 ) ;
317+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
318+
319+ t . end ( ) ;
320+ } ) ;
321+
290322tape ( 'if provided an `N` parameter equal to `1`, the function returns a sample variance equal to `NaN`' , function test ( t ) {
291323 var x ;
292324 var v ;
@@ -304,6 +336,23 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a sample
304336 t . end ( ) ;
305337} ) ;
306338
339+ tape ( 'if provided an `N` parameter equal to `1`, the function returns a sample variance equal to `NaN` (accessors)' , function test ( t ) {
340+ var x ;
341+ var v ;
342+
343+ x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
344+
345+ v = nanvariancewd ( 1 , 1 , toAccessorArray ( x ) , 1 , 0 ) ;
346+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
347+
348+ x = [ NaN , 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
349+
350+ v = nanvariancewd ( 1 , 1 , toAccessorArray ( x ) , 1 , 0 ) ;
351+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
352+
353+ t . end ( ) ;
354+ } ) ;
355+
307356tape ( 'if provided a `correction` parameter yielding a correction term less than or equal to `0`, the function returns `NaN`' , function test ( t ) {
308357 var x ;
309358 var v ;
@@ -319,6 +368,21 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
319368 t . end ( ) ;
320369} ) ;
321370
371+ tape ( 'if provided a `correction` parameter yielding a correction term less than or equal to `0`, the function returns `NaN` (accessors)' , function test ( t ) {
372+ var x ;
373+ var v ;
374+
375+ x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
376+
377+ v = nanvariancewd ( x . length , x . length , toAccessorArray ( x ) , 1 , 0 ) ;
378+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
379+
380+ v = nanvariancewd ( x . length , x . length + 1 , toAccessorArray ( x ) , 1 , 0 ) ;
381+ t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
382+
383+ t . end ( ) ;
384+ } ) ;
385+
322386tape ( 'the function supports a `stride` parameter' , function test ( t ) {
323387 var x ;
324388 var v ;
0 commit comments