| import Builder from '../Builder.js'; |
| import * as assert from '../assert.js'; |
| const memoryDescription = {initial: 0, maximum: 2}; |
| const builder = (new Builder()) |
| .Memory("imp", "memory", memoryDescription) |
| .Function("foo", {params: [], ret: "void"}) |
| .Function("bar", {params: [], ret: "void"}) |
| const bin = builder.WebAssembly().get(); |
| const module = new WebAssembly.Module(bin); // Just make sure it parses. |
| const memory = new WebAssembly.Memory(memoryDescription); |
| const instance = new WebAssembly.Instance(module, {imp: {memory}}); |
| assert.throws(() => instance.exports.foo(), WebAssembly.RuntimeError, "Unreachable code should not be executed") |
| assert.throws(() => instance.exports.bar(), WebAssembly.RuntimeError, "Unreachable code should not be executed") |