Skip to content

Commit f14a8d4

Browse files
committed
test: add accessor tests
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 28a9149 commit f14a8d4

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

lib/node_modules/@stdlib/stats/base/nanmeanwd/test/test.main.js renamed to lib/node_modules/@stdlib/stats/base/nanmeanwd/test/test.nanmeanwd.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
9999
t.end();
100100
});
101101

102+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
103+
var x;
104+
var v;
105+
106+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
107+
108+
v = nanmeanwd( 0, toAccessorArray( x ), 1 );
109+
t.strictEqual( isnan( v ), true, 'returns expected value' );
110+
111+
v = nanmeanwd( -1, toAccessorArray( x ), 1 );
112+
t.strictEqual( isnan( v ), true, 'returns expected value' );
113+
114+
t.end();
115+
});
116+
102117
tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', function test( t ) {
103118
var x;
104119
var v;
@@ -111,6 +126,18 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
111126
t.end();
112127
});
113128

129+
tape( 'if provided an `N` parameter equal to `1`, the function returns the first element (accessors)', function test( t ) {
130+
var x;
131+
var v;
132+
133+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
134+
135+
v = nanmeanwd( 1, toAccessorArray( x ), 1 );
136+
t.strictEqual( v, 1.0, 'returns expected value' );
137+
138+
t.end();
139+
});
140+
114141
tape( 'the function supports a `stride` parameter', function test( t ) {
115142
var x;
116143
var v;
@@ -253,3 +280,30 @@ tape( 'the function supports view offsets', function test( t ) {
253280

254281
t.end();
255282
});
283+
284+
tape( 'the function supports view offsets (accessors)', function test( t ) {
285+
var x0;
286+
var x1;
287+
var v;
288+
289+
x0 = new Float64Array([
290+
2.0,
291+
1.0, // 0
292+
2.0,
293+
-2.0, // 1
294+
-2.0,
295+
2.0, // 2
296+
3.0,
297+
4.0, // 3
298+
6.0,
299+
NaN, // 4
300+
NaN
301+
]);
302+
303+
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
304+
305+
v = nanmeanwd( 5, toAccessorArray( x1 ), 2 );
306+
t.strictEqual( v, 1.25, 'returns expected value' );
307+
308+
t.end();
309+
});

lib/node_modules/@stdlib/stats/base/nanmeanwd/test/test.ndarray.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
9898
t.end();
9999
});
100100

101+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
102+
var x;
103+
var v;
104+
105+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
106+
107+
v = nanmeanwd( 0, toAccessorArray( x ), 1, 0 );
108+
t.strictEqual( isnan( v ), true, 'returns expected value' );
109+
110+
v = nanmeanwd( -1, toAccessorArray( x ), 1, 0 );
111+
t.strictEqual( isnan( v ), true, 'returns expected value' );
112+
113+
t.end();
114+
});
115+
101116
tape( 'if provided an `N` parameter equal to `1`, the function returns the first indexed element', function test( t ) {
102117
var x;
103118
var v;
@@ -110,6 +125,18 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
110125
t.end();
111126
});
112127

128+
tape( 'if provided an `N` parameter equal to `1`, the function returns the first indexed element (accessors)', function test( t ) {
129+
var x;
130+
var v;
131+
132+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
133+
134+
v = nanmeanwd( 1, toAccessorArray( x ), 1, 0 );
135+
t.strictEqual( v, 1.0, 'returns expected value' );
136+
137+
t.end();
138+
});
139+
113140
tape( 'the function supports a `stride` parameter', function test( t ) {
114141
var x;
115142
var v;

0 commit comments

Comments
 (0)