mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 01:11:32 +00:00
more loader updates
This commit is contained in:
@ -58,3 +58,5 @@ export function calladd(fn: (a: i32, b: i32) => i32, a: i32, b: i32): i32 {
|
||||
export function dotrace(num: f64): void {
|
||||
trace("The answer is", 1, num);
|
||||
}
|
||||
|
||||
export const INT32ARRAY_ID = idof<Int32Array>();
|
||||
|
Binary file not shown.
@ -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