Skip to content

Commit 72010c1

Browse files
committed
test: add coverage for invalid array element conversion
--- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - 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 50a17db commit 72010c1

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • lib/node_modules/@stdlib/array/uint64/test

lib/node_modules/@stdlib/array/uint64/test/test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,30 @@ tape( 'the constructor throws an error if provided an iterable object which retu
707707
}
708708
});
709709

710+
tape( 'the constructor throws an error if provided an array containing values which cannot be converted to 64-bit unsigned integers', function test( t ) {
711+
var values;
712+
var i;
713+
714+
values = [
715+
[ 1.5 ],
716+
[ -1 ],
717+
[ NaN ],
718+
[ {} ],
719+
[ [] ],
720+
[ function noop() {} ]
721+
];
722+
for ( i = 0; i < values.length; i++ ) {
723+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided ' + values[i] );
724+
}
725+
t.end();
726+
727+
function badValue( value ) {
728+
return function badValue() {
729+
return new Uint64Array( value );
730+
};
731+
}
732+
});
733+
710734
tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) {
711735
var values;
712736
var i;

0 commit comments

Comments
 (0)