Skip to content

Commit 947054f

Browse files
committed
test: add missing test cases
--- 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 e842e22 commit 947054f

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,35 @@ tape( 'the function throws an error if provided a first argument which is not an
461461
}
462462
});
463463

464+
tape( 'the function throws an error if provided a first argument which is a zero-dimensional ndarray', function test( t ) {
465+
var values;
466+
var opts;
467+
var i;
468+
var y;
469+
470+
opts = {
471+
'dtype': 'generic'
472+
};
473+
474+
y = zeros( [], opts );
475+
476+
values = [
477+
scalar2ndarray( 10.0 ),
478+
scalar2ndarray( -3.0 ),
479+
scalar2ndarray( 0.0 )
480+
];
481+
for ( i = 0; i < values.length; i++ ) {
482+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
483+
}
484+
t.end();
485+
486+
function badValue( value ) {
487+
return function badValue() {
488+
lastIndexOf( value, scalar2ndarray( 2.0 ), scalar2ndarray( 0, opts ), y, {} ); // eslint-disable-line max-len
489+
};
490+
}
491+
});
492+
464493
tape( 'the function throws an error if provided a third argument which is not an ndarray-like object, an integer, or an object', function test( t ) {
465494
var values;
466495
var i;
@@ -495,6 +524,40 @@ tape( 'the function throws an error if provided a third argument which is not an
495524
}
496525
});
497526

527+
tape( 'the function throws an error if provided a third argument which is not an ndarray-like object or an integer', function test( t ) {
528+
var values;
529+
var i;
530+
var x;
531+
var y;
532+
533+
x = zeros( [ 2, 2 ], {
534+
'dtype': 'float64'
535+
});
536+
y = zeros( [], {
537+
'dtype': 'generic'
538+
});
539+
values = [
540+
'5',
541+
NaN,
542+
true,
543+
false,
544+
null,
545+
void 0,
546+
[],
547+
function noop() {}
548+
];
549+
for ( i = 0; i < values.length; i++ ) {
550+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
551+
}
552+
t.end();
553+
554+
function badValue( value ) {
555+
return function badValue() {
556+
lastIndexOf( x, scalar2ndarray( 2.0 ), value, y, {} );
557+
};
558+
}
559+
});
560+
498561
tape( 'the function throws an error if provided an output argument which is not an ndarray-like object', function test( t ) {
499562
var values;
500563
var opts;

lib/node_modules/@stdlib/blas/ext/last-index-of/test/test.main.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,32 @@ tape( 'the function throws an error if provided a first argument which is not an
385385
}
386386
});
387387

388+
tape( 'the function throws an error if provided a first argument which is a zero-dimensional ndarray', function test( t ) {
389+
var values;
390+
var opts;
391+
var i;
392+
393+
opts = {
394+
'dtype': 'generic'
395+
};
396+
397+
values = [
398+
scalar2ndarray( 10.0 ),
399+
scalar2ndarray( -3.0 ),
400+
scalar2ndarray( 0.0 )
401+
];
402+
for ( i = 0; i < values.length; i++ ) {
403+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
404+
}
405+
t.end();
406+
407+
function badValue( value ) {
408+
return function badValue() {
409+
lastIndexOf( value, scalar2ndarray( 2.0 ), scalar2ndarray( 0, opts ), {} ); // eslint-disable-line max-len
410+
};
411+
}
412+
});
413+
388414
tape( 'the function throws an error if provided a third argument which is not an ndarray-like object, an integer or an object', function test( t ) {
389415
var values;
390416
var x;
@@ -988,6 +1014,74 @@ tape( 'the function supports specifying the operation dimension (column-major)',
9881014
t.end();
9891015
});
9901016

1017+
tape( 'the function supports specifying the `keepdims` option (row-major)', function test( t ) {
1018+
var expected;
1019+
var actual;
1020+
var xbuf;
1021+
var x;
1022+
1023+
xbuf = [ -1.0, 2.0, -3.0, 2.0 ];
1024+
x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
1025+
1026+
actual = lastIndexOf( x, 2.0, {
1027+
'keepdims': true
1028+
});
1029+
expected = [ [ -1 ], [ -1 ] ];
1030+
1031+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1032+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1033+
t.deepEqual( getShape( actual ), [ 2, 1 ], 'returns expected value' );
1034+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1035+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1036+
1037+
actual = lastIndexOf( x, 2.0, 0, {
1038+
'keepdims': true
1039+
});
1040+
expected = [ [ -1 ], [ -1 ] ];
1041+
1042+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1043+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1044+
t.deepEqual( getShape( actual ), [ 2, 1 ], 'returns expected value' );
1045+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1046+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1047+
1048+
t.end();
1049+
});
1050+
1051+
tape( 'the function supports specifying the `keepdims` option (column-major)', function test( t ) {
1052+
var expected;
1053+
var actual;
1054+
var xbuf;
1055+
var x;
1056+
1057+
xbuf = [ -1.0, 2.0, -3.0, 2.0 ];
1058+
x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
1059+
1060+
actual = lastIndexOf( x, 2.0, {
1061+
'keepdims': true
1062+
});
1063+
expected = [ [ -1 ], [ -1 ] ];
1064+
1065+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1066+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1067+
t.deepEqual( getShape( actual ), [ 2, 1 ], 'returns expected value' );
1068+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1069+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1070+
1071+
actual = lastIndexOf( x, 2.0, 0, {
1072+
'keepdims': true
1073+
});
1074+
expected = [ [ -1 ], [ -1 ] ];
1075+
1076+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1077+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1078+
t.deepEqual( getShape( actual ), [ 2, 1 ], 'returns expected value' );
1079+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1080+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1081+
1082+
t.end();
1083+
});
1084+
9911085
tape( 'the function supports specifying the output array data type', function test( t ) {
9921086
var expected;
9931087
var actual;

0 commit comments

Comments
 (0)