Skip to content

Commit a51a1a2

Browse files
committed
test: add tests for a fromIndex ndarray
--- 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 1f2836f commit a51a1a2

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var ndarray = require( '@stdlib/ndarray/ctor' );
2626
var zeros = require( '@stdlib/ndarray/zeros' );
2727
var ndarray2array = require( '@stdlib/ndarray/to-array' );
2828
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
29+
var Int32Array = require( '@stdlib/array/int32' );
2930
var getDType = require( '@stdlib/ndarray/dtype' );
3031
var getShape = require( '@stdlib/ndarray/shape' );
3132
var getOrder = require( '@stdlib/ndarray/order' );
@@ -1155,7 +1156,7 @@ tape( 'the function returns the first index of a specified search element in an
11551156
t.end();
11561157
});
11571158

1158-
tape( 'the function supports specifying operation dimensions (row-major)', function test( t ) {
1159+
tape( 'the function supports specifying an operation dimension (row-major)', function test( t ) {
11591160
var expected;
11601161
var actual;
11611162
var xbuf;
@@ -1680,3 +1681,44 @@ tape( 'the function supports providing a from index (0d ndarray, broadcasted)',
16801681

16811682
t.end();
16821683
});
1684+
1685+
tape( 'the function supports providing a from index (ndarray)', function test( t ) {
1686+
var searchElement;
1687+
var expected;
1688+
var fromIdx;
1689+
var actual;
1690+
var xbuf;
1691+
var x;
1692+
var y;
1693+
1694+
/*
1695+
* [
1696+
* 1.0, -2.0,
1697+
* 2.0, -3.0,
1698+
* 3.0, -4.0,
1699+
* 2.0, -3.0,
1700+
* 5.0, -6.0
1701+
* ]
1702+
*/
1703+
xbuf = [ 1.0, -2.0, 2.0, -3.0, 3.0, -4.0, 2.0, -3.0, 5.0, -6.0 ];
1704+
x = new ndarray( 'generic', xbuf, [ 5, 2 ], [ 2, 1 ], 0, 'row-major' );
1705+
y = zeros( [ 2 ], {
1706+
'dtype': 'generic'
1707+
});
1708+
1709+
fromIdx = new ndarray( 'int32', new Int32Array( [ 2, 2 ] ), [ 2 ], [ 1 ], 0, 'row-major' );
1710+
searchElement = new ndarray( 'generic', [ 2.0, -3.0 ], [ 2 ], [ 1 ], 0, 'row-major' );
1711+
actual = indexOf( x, searchElement, fromIdx, y, {
1712+
'dim': 0
1713+
});
1714+
expected = [ 3, 3 ];
1715+
1716+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1717+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1718+
t.deepEqual( getShape( actual ), [ 2 ], 'returns expected value' );
1719+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1720+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1721+
t.strictEqual( ( y === actual ), true, 'returns expected value' );
1722+
1723+
t.end();
1724+
});

0 commit comments

Comments
 (0)