mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 17:31:29 +00:00
more loader updates
This commit is contained in:
@ -33,17 +33,19 @@ assert.strictEqual(module.getString(ptr), str);
|
||||
assert.strictEqual(module.strlen(ptr), str.length);
|
||||
|
||||
// should be able to allocate a typed array and sum up its values
|
||||
// var arr = [1, 2, 3, 4, 5, 0x7fffffff];
|
||||
// ptr = module.newArray(new Int32Array(arr));
|
||||
// assert.strictEqual(module.sum(ptr), arr.reduce((a, b) => a + b, 0) | 0);
|
||||
var arr = [1, 2, 3, 4, 5, 0x7fffffff];
|
||||
ptr = module.newArray(module.INT32ARRAY_ID, arr);
|
||||
assert.strictEqual(module.sum(ptr), arr.reduce((a, b) => a + b, 0) | 0);
|
||||
|
||||
// should be able to get a view on an internal typed array
|
||||
// assert.deepEqual(module.getArray(Int32Array, ptr), arr);
|
||||
assert.deepEqual(Array.from(module.getArray(ptr)), arr);
|
||||
|
||||
// should be able to free and reuse the space of an internal typed array
|
||||
// module.freeArray(ptr);
|
||||
// var ptr2 = module.newArray(new Int32Array(arr));
|
||||
// assert.strictEqual(ptr, ptr2);
|
||||
// should be able to release no longer needed references
|
||||
module.__release(ptr);
|
||||
try {
|
||||
module.__release(ptr);
|
||||
assert(false);
|
||||
} catch (e) {};
|
||||
|
||||
// should be able to just call a function with variable arguments
|
||||
assert.strictEqual(module.varadd(), 3);
|
||||
|
Reference in New Issue
Block a user