blob: a93913970a4a50d2626ec1ba625dd20df8c32de6 [file] [log] [blame]
import * as assert from '../assert.js';
import Builder from '../Builder.js';
async function test() {
let builder = (new Builder())
.Type().End()
.Function().End()
.Export()
.Function("foo")
.End()
.Code()
.Function("foo", { params: [], ret: "i32" })
.I32Const(42)
.Return()
.End()
.End();
const bin = builder.WebAssembly().get();
const {instance} = await WebAssembly.instantiate(bin, {});
for (let i = 0; i < 1000000; i++)
assert.eq(instance.exports.foo(), 42);
}
assert.asyncTest(test());