Skip to content

Commit 771492b

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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent fa99780 commit 771492b

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

lib/node_modules/@stdlib/blas/ext/find-index/test/test.assign.js

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,150 @@ tape( 'the function throws an error if provided a second argument which is not a
319319
}
320320
});
321321

322+
tape( 'the function throws an error if provided a callback which is not a function', function test( t ) {
323+
var values;
324+
var i;
325+
var x;
326+
var y;
327+
328+
x = zeros( [], {
329+
'dtype': 'generic'
330+
});
331+
x = zeros( [], {
332+
'dtype': 'int32'
333+
});
334+
335+
values = [
336+
'5',
337+
5,
338+
NaN,
339+
true,
340+
false,
341+
null,
342+
void 0,
343+
[],
344+
{}
345+
];
346+
for ( i = 0; i < values.length; i++ ) {
347+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
348+
}
349+
t.end();
350+
351+
function badValue( value ) {
352+
return function badValue() {
353+
findIndex( x, y, value );
354+
};
355+
}
356+
});
357+
358+
tape( 'the function throws an error if provided a callback which is not a function (thisArg)', function test( t ) {
359+
var values;
360+
var i;
361+
var x;
362+
var y;
363+
364+
x = zeros( [], {
365+
'dtype': 'generic'
366+
});
367+
x = zeros( [], {
368+
'dtype': 'int32'
369+
});
370+
371+
values = [
372+
'5',
373+
5,
374+
NaN,
375+
true,
376+
false,
377+
null,
378+
void 0,
379+
[],
380+
{}
381+
];
382+
for ( i = 0; i < values.length; i++ ) {
383+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
384+
}
385+
t.end();
386+
387+
function badValue( value ) {
388+
return function badValue() {
389+
findIndex( x, y, value, {} );
390+
};
391+
}
392+
});
393+
394+
tape( 'the function throws an error if provided a callback which is not a function (options)', function test( t ) {
395+
var values;
396+
var i;
397+
var x;
398+
var y;
399+
400+
x = zeros( [], {
401+
'dtype': 'generic'
402+
});
403+
y = zeros( [], {
404+
'dtype': 'int32'
405+
});
406+
407+
values = [
408+
'5',
409+
5,
410+
NaN,
411+
true,
412+
false,
413+
null,
414+
void 0,
415+
[],
416+
{}
417+
];
418+
for ( i = 0; i < values.length; i++ ) {
419+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
420+
}
421+
t.end();
422+
423+
function badValue( value ) {
424+
return function badValue() {
425+
findIndex( x, y, value, {}, clbk );
426+
};
427+
}
428+
});
429+
430+
tape( 'the function throws an error if provided a callback which is not a function (options, thisArg)', function test( t ) {
431+
var values;
432+
var i;
433+
var x;
434+
var y;
435+
436+
x = zeros( [], {
437+
'dtype': 'generic'
438+
});
439+
x = zeros( [], {
440+
'dtype': 'int32'
441+
});
442+
443+
values = [
444+
'5',
445+
5,
446+
NaN,
447+
true,
448+
false,
449+
null,
450+
void 0,
451+
[],
452+
{}
453+
];
454+
for ( i = 0; i < values.length; i++ ) {
455+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
456+
}
457+
t.end();
458+
459+
function badValue( value ) {
460+
return function badValue() {
461+
findIndex( x, y, {}, value, {} );
462+
};
463+
}
464+
});
465+
322466
tape( 'the function throws an error if provided insufficient number of arguments', function test( t ) {
323467
var x;
324468
var y;

0 commit comments

Comments
 (0)