1 import * as assert from '../assert.js';
2 import Builder from '../Builder.js';
4 (function StartNamedFunction() {
5 const b = (new Builder())
8 .Function("imp", "func", { params: ["i32"] })
13 .Function("foo", { params: [] })
15 .Call(0) // Calls func(42).
18 const bin = b.WebAssembly().get();
19 const module = new WebAssembly.Module(bin);
21 const setter = v => value = v;
22 const instance = new WebAssembly.Instance(module, { imp: { func: setter } });
26 (function InvalidStartFunctionIndex() {
27 const b = (new Builder())
31 .Start(0).End() // Invalid index.
33 const bin = b.WebAssembly().get();
34 assert.throws(() => new WebAssembly.Module(bin), Error, `couldn't parse section Start: Start function declaration (evaluating 'new WebAssembly.Module(bin)')`);