support normal arrays

This commit is contained in:
dcode
2019-05-25 01:14:26 +02:00
parent 9620f18249
commit c34ed66fd9
42 changed files with 831 additions and 468 deletions

View File

@ -72,6 +72,17 @@ assert.strictEqual(module.__getString(module.COLOR), "red");
try { module.__release(ref); assert(false); } catch (e) {};
}
// should be able to work with normal arrays
{
let arr = [1, 2, 3, 4, 5];
let ref = module.__retain(module.__allocArray(module.ARRAYI32_ID, arr));
assert(module.__instanceof(ref, module.ARRAYI32_ID));
module.changeLength(ref, 3);
assert.deepEqual(module.__getArray(ref), [1, 2, 3]);
module.__release(ref);
try { module.__release(ref); assert(false); } catch (e) {};
}
// should be able to correctly call a function with variable arguments
assert.strictEqual(module.varadd(), 3);
assert.strictEqual(module.varadd(2, 3), 5);