blob: 59f4c2e9031e9ed49de6971c971b640bee24afc3 [file] [log] [blame]
import Builder from '../Builder.js'
import * as assert from '../assert.js'
{
const b = new Builder();
b.Type().End()
.Import().Function("context", "callback", { params: [], ret: "void" }).End()
.Function().End()
.Exception().Signature({ params: []}).End()
.Export().Function("call")
.Exception("foo", 0)
.End()
.Code()
.Function("call", { params: [], ret: "i32" })
.Call(0)
.I32Const(1)
.End()
.End()
const bin = b.WebAssembly().get();
const module = new WebAssembly.Module(bin);
const instance = new WebAssembly.Instance(module, { context: { callback }});
function callback() {
throw new WebAssembly.Exception(instance.exports.foo, []);
}
assert.throws(instance.exports.call, WebAssembly.Exception, "wasm exception");
}