Skip to content

Commit c53a29f

Browse files
committed
test: add test case for accessor array buffers
--- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 0b89951 commit c53a29f

File tree

1 file changed

+32
-0
lines changed
  • lib/node_modules/@stdlib/ndarray/base/ctor/test

1 file changed

+32
-0
lines changed

lib/node_modules/@stdlib/ndarray/base/ctor/test/test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
2727
var Complex64Array = require( '@stdlib/array/complex64' );
2828
var Complex128Array = require( '@stdlib/array/complex128' );
2929
var BooleanArray = require( '@stdlib/array/bool' );
30+
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
3031
var Complex64 = require( '@stdlib/complex/float32/ctor' );
3132
var Complex128 = require( '@stdlib/complex/float64/ctor' );
3233
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
@@ -3508,6 +3509,37 @@ tape( 'an ndarray has a custom `toString()` method (boolean type)', function tes
35083509
t.end();
35093510
});
35103511

3512+
tape( 'an ndarray has a custom `toString()` method (underlying accessor array)', function test( t ) {
3513+
var expected;
3514+
var strides;
3515+
var actual;
3516+
var buffer;
3517+
var offset;
3518+
var dtype;
3519+
var order;
3520+
var shape;
3521+
var arr;
3522+
3523+
dtype = 'generic';
3524+
buffer = toAccessorArray( [ 1, 0, 1, 0 ] );
3525+
shape = [ 2, 2 ];
3526+
order = 'row-major';
3527+
strides = [ 2, 1 ];
3528+
offset = 0;
3529+
3530+
arr = ndarray( dtype, buffer, shape, strides, offset, order );
3531+
3532+
t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' );
3533+
t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' );
3534+
t.strictEqual( isFunction( arr.toString ), true, 'has method' );
3535+
3536+
expected = 'ndarray( \'generic\', [ 1, 0, 1, 0 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )';
3537+
actual = arr.toString();
3538+
t.strictEqual( actual, expected, 'returns expected value' );
3539+
3540+
t.end();
3541+
});
3542+
35113543
tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) {
35123544
var expected;
35133545
var strides;

0 commit comments

Comments
 (0)