mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 00:41:32 +00:00
array is an abv, views
This commit is contained in:
Binary file not shown.
@ -41,9 +41,12 @@ assert.strictEqual(module.__getString(module.COLOR), "red");
|
||||
let ref = module.__retain(module.__allocArray(module.INT32ARRAY_ID, arr));
|
||||
assert(module.__instanceof(ref, module.INT32ARRAY_ID));
|
||||
|
||||
// should be able to get a view on an internal typed array
|
||||
// should be able to get the values of an array
|
||||
assert.deepEqual(module.__getArray(ref), arr);
|
||||
|
||||
// should be able to get a view on an array
|
||||
assert.deepEqual(module.__getArrayView(ref), new Int32Array(arr));
|
||||
|
||||
// should be able to sum up its values
|
||||
assert.strictEqual(module.sum(ref), arr.reduce((a, b) => (a + b) | 0, 0) | 0);
|
||||
|
||||
|
Reference in New Issue
Block a user