Skip to content

Commit 1af09dd

Browse files
committed
test: add test
--- 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 a1c44de commit 1af09dd

File tree

1 file changed

+27
-0
lines changed
  • lib/node_modules/@stdlib/ndarray/with/test

1 file changed

+27
-0
lines changed

lib/node_modules/@stdlib/ndarray/with/test/test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ tape( 'the function throws an error if provided a second argument with out-of-bo
121121
}
122122
});
123123

124+
tape( 'the function throws an error if provided a second argument whose length does not match the number of dimensions', function test( t ) {
125+
var values;
126+
var x;
127+
var i;
128+
129+
x = zeros( [ 3, 3, 3 ], {
130+
'dtype': 'float64'
131+
});
132+
values = [
133+
[],
134+
[ 0 ],
135+
[ 0, 0 ],
136+
[ 0, 0, 0, 0 ],
137+
[ 0, 0, 0, 0, 0 ]
138+
];
139+
for ( i = 0; i < values.length; i++ ) {
140+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
141+
}
142+
t.end();
143+
144+
function badValue( value ) {
145+
return function badValue() {
146+
ndarrayWith( x, value, 5 );
147+
};
148+
}
149+
});
150+
124151
tape( 'the function returns a new ndarray with the element at a specified index replaced by a provided value', function test( t ) {
125152
var out;
126153
var x;

0 commit comments

Comments
 (0)