Skip to content

Commit 9cdec3c

Browse files
committed
update the test case
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 9ab1869 commit 9cdec3c

File tree

1 file changed

+23
-11
lines changed
  • lib/node_modules/@stdlib/stats/incr/nanrange/test

1 file changed

+23
-11
lines changed

lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,41 +54,39 @@ tape( 'the accumulator function incrementally computes a range while ignoring Na
5454
var d;
5555
var i;
5656

57-
data = [ 2.0, 3.0, NaN, 2.0, 4.0, NaN, 3.0, 4.0 ];
57+
data = [ 2.0, NaN, 3.0, NaN, 4.0, 43.0, NaN, 4.0 ];
5858
N = data.length;
5959

60-
expected = new Array( N );
61-
actual = new Array( N );
60+
expected = [];
61+
actual = [];
6262

6363
acc = incrnanrange();
6464

6565
max = null;
6666
min = null;
6767
for ( i = 0; i < N; i++ ) {
6868
d = data[ i ];
69-
if ( isnan( d ) === false ) {
69+
if ( !isnan( d ) ) {
7070
if ( max === null || d > max ) {
7171
max = d;
7272
}
7373
if ( min === null || d < min ) {
7474
min = d;
7575
}
76-
expected[ i ] = max - min;
77-
} else {
78-
expected[ i ] = expected[i-1];
7976
}
80-
actual[ i ] = acc( d );
77+
expected.push( max !== null && min !== null ? max - min : null );
78+
actual.push( acc( d ) );
8179
}
8280
t.deepEqual( actual, expected, 'returns expected incremental results' );
8381
t.end();
8482
});
8583

86-
tape( 'if not provided an input value, the accumulator function returns the current range', function test( t ) {
84+
tape( 'if not provided an input value, the accumulator function returns the current range while ignoring the NaN value', function test( t ) {
8785
var data;
8886
var acc;
8987
var i;
9088

91-
data = [ -2.0, NaN, 3.0, 1.0, NaN ];
89+
data = [ NaN, -2.0, NaN, 3.0, 1.0 ];
9290
acc = incrnanrange();
9391
for ( i = 0; i < data.length; i++ ) {
9492
acc( data[ i ] );
@@ -107,6 +105,20 @@ tape( 'if provided a `NaN`, the accumulator function returns `NaN` for all futur
107105
for ( i = 0; i < data.length; i++ ) {
108106
acc( data[ i ] );
109107
}
110-
t.equal( isnan( acc() ), true, 'returns expected value' );
108+
t.equal( isnan( acc() ), false, 'returns expected value' );
109+
t.end();
110+
});
111+
112+
tape( 'if all provided values are `NaN`, the accumulator function returns `null`', function test( t ) {
113+
var data;
114+
var acc;
115+
var i;
116+
117+
data = [ NaN, NaN, NaN ];
118+
acc = incrnanrange();
119+
for ( i = 0; i < data.length; i++ ) {
120+
acc( data[ i ] );
121+
}
122+
t.equal( acc(), null, 'returns null' );
111123
t.end();
112124
});

0 commit comments

Comments
 (0)