Skip to content

Commit 492a016

Browse files
committed
test: add accessors test cases
--- 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 81cd50a commit 492a016

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

lib/node_modules/@stdlib/stats/base/nanmeanors/test/test.main.js

Lines changed: 26 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 = nanmeanors( 0, toAccessorArray( x ), 1 );
109+
t.strictEqual( isnan( v ), true, 'returns expected value' );
110+
111+
v = nanmeanors( -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;
@@ -110,6 +125,17 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
110125

111126
t.end();
112127
});
128+
tape( 'if provided an `N` parameter equal to `1`, the function returns the first 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 = nanmeanors( 1, toAccessorArray( x ), 1 );
135+
t.strictEqual( v, 1.0, 'returns expected value' );
136+
137+
t.end();
138+
});
113139

114140
tape( 'the function supports a `stride` parameter', function test( t ) {
115141
var x;

lib/node_modules/@stdlib/stats/base/nanmeanors/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 = nanmeanors( 0, toAccessorArray( x ), 1, 0 );
108+
t.strictEqual( isnan( v ), true, 'returns expected value' );
109+
110+
v = nanmeanors( -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 = nanmeanors( 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)