Skip to content

Commit 93406df

Browse files
committed
test: add missing 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f91aca6 commit 93406df

File tree

1 file changed

+52
-0
lines changed
  • lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/test

1 file changed

+52
-0
lines changed

lib/node_modules/@stdlib/ndarray/base/broadcast-array-except-dimensions/test/test.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,58 @@ tape( 'the function throws an error if provided a desired shape and an input arr
123123
}
124124
});
125125

126+
tape( 'the function throws an error if provided duplicate dimensions', function test( t ) {
127+
var values;
128+
var x;
129+
var i;
130+
131+
x = array({
132+
'shape': [ 2, 10, 10 ]
133+
});
134+
135+
values = [
136+
[ -3, -3 ],
137+
[ -2, -2 ],
138+
[ -1, -1 ]
139+
];
140+
for ( i = 0; i < values.length; i++ ) {
141+
t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ['+values[ i ].join( ',')+']' );
142+
}
143+
t.end();
144+
145+
function badValue( value ) {
146+
return function badValue() {
147+
broadcastArrayExceptDimensions( x, [ 2, 10, 10 ], value );
148+
};
149+
}
150+
});
151+
152+
tape( 'the function throws an error if provided out-of-bounds dimensions', function test( t ) {
153+
var values;
154+
var x;
155+
var i;
156+
157+
x = array({
158+
'shape': [ 2, 10, 10 ]
159+
});
160+
161+
values = [
162+
[ -4 ],
163+
[ -5 ],
164+
[ -6 ]
165+
];
166+
for ( i = 0; i < values.length; i++ ) {
167+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ['+values[ i ].join( ',')+']' );
168+
}
169+
t.end();
170+
171+
function badValue( value ) {
172+
return function badValue() {
173+
broadcastArrayExceptDimensions( x, [ 2, 10, 10 ], value );
174+
};
175+
}
176+
});
177+
126178
tape( 'the function returns a "base" ndarray instance', function test( t ) {
127179
var x;
128180
var y;

0 commit comments

Comments
 (0)