mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 02:11:31 +00:00
Update Binaryen to latest; Various fixes
This commit is contained in:
@ -18,8 +18,6 @@ assert(proto.I32 instanceof Int32Array);
|
||||
assert(proto.U32 instanceof Uint32Array);
|
||||
assert(proto.F32 instanceof Float32Array);
|
||||
assert(proto.F64 instanceof Float64Array);
|
||||
assert(typeof proto.newString === "function");
|
||||
assert(typeof proto.getString === "function");
|
||||
|
||||
// should export memory
|
||||
assert(module.memory instanceof WebAssembly.Memory);
|
||||
@ -46,3 +44,18 @@ assert.deepEqual(module.getArray(Int32Array, ptr), arr);
|
||||
module.freeArray(ptr);
|
||||
var ptr2 = module.newArray(new Int32Array(arr));
|
||||
assert.strictEqual(ptr, ptr2);
|
||||
|
||||
// should be able to just call a function with variable arguments
|
||||
assert.strictEqual(module.varadd(), 3);
|
||||
assert.strictEqual(module.varadd(2, 3), 5);
|
||||
assert.strictEqual(module.varadd(2), 4);
|
||||
|
||||
// should be able to get a function from the table and just call it with variable arguments
|
||||
var fn = module.getFunction(module.varadd_ptr);
|
||||
assert.strictEqual(fn(), 3);
|
||||
assert.strictEqual(fn(2, 3), 5);
|
||||
assert.strictEqual(fn(2), 4);
|
||||
|
||||
// should be able to create a new function and call it from WASM
|
||||
ptr = module.newFunction(module.varadd.constructor); // must be an actual exported wasm function
|
||||
assert.strictEqual(module.calladd(ptr, 2, 3), 5);
|
||||
|
Reference in New Issue
Block a user