Skip to content

Commit bbc7979

Browse files
committed
fix: add missing assertion and update 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: passed - 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 1af09dd commit bbc7979

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
24+
var isCollection = require( '@stdlib/assert/is-collection' );
2425
var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
2526
var getShape = require( '@stdlib/ndarray/shape' );
2627
var emptyLike = require( '@stdlib/ndarray/empty-like' );
@@ -73,6 +74,9 @@ function ndarrayWith( x, indices, value ) {
7374
if ( !isndarrayLike( x ) ) {
7475
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
7576
}
77+
if ( !isCollection( indices ) ) {
78+
throw new TypeError( format( 'invalid argument. Second argument must be an array of integers. Value: `%s`.', indices ) );
79+
}
7680
sh = getShape( x );
7781
if ( indices.length !== sh.length ) {
7882
throw new RangeError( format( 'invalid argument. Number of indices does not match the number of array dimensions. Array shape: (%s). Number of indices: %u.', join( sh, ',' ), indices.length ) );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ tape( 'the function throws an error if provided a second argument which is not a
7777
false,
7878
null,
7979
void 0,
80-
[ '1' ],
80+
[ 0, '1', 0 ],
8181
{},
8282
function noop() {}
8383
];

0 commit comments

Comments
 (0)