Skip to content

Commit 4eb2421

Browse files
committed
Auto-generated commit
1 parent fe2005f commit 4eb2421

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
<details>
3636

37+
- [`c53a29f`](https://github.com/stdlib-js/stdlib/commit/c53a29fc1e8048c4a4454d7a806d7ea1d2e6f326) - **test:** add test case for accessor array buffers _(by Athan Reines)_
3738
- [`0b89951`](https://github.com/stdlib-js/stdlib/commit/0b89951e22829e302f05d948ac8391d6300a39ea) - **fix:** serialize the data type to a string and add comment _(by Athan Reines)_
3839
- [`18f1915`](https://github.com/stdlib-js/stdlib/commit/18f191560f9322727ee126619e9e083187b64821) - **chore:** minor clean-up _(by Philipp Burckhardt)_
3940
- [`ebd5886`](https://github.com/stdlib-js/stdlib/commit/ebd5886f97aef9dad8daf7df0d850882a767ca6b) - **fix:** preserve formatting of original string serialization and rename internal files _(by Athan Reines)_

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@stdlib/error-tools-fmtprodmsg": "^0.2.3"
7171
},
7272
"devDependencies": {
73+
"@stdlib/array-base-to-accessor-array": "^0.2.3",
7374
"@stdlib/array-bool": "^0.1.2",
7475
"@stdlib/array-complex128": "^0.3.2",
7576
"@stdlib/array-complex64": "^0.3.2",

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)