more loader updates

This commit is contained in:
dcode
2019-05-24 20:31:52 +02:00
parent 7cd04b65ef
commit a6896d7bc2
12 changed files with 225 additions and 141 deletions

View File

@ -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);