Reusable WebAssembly specification model for parsers, validators, and frontends
///|
test "build a module with one exported function" {
let mod_ = simple_module([I32], [I64], [I64Const(7L)], "answer")
inspect(mod_.funcs.length(), content="1")
inspect(mod_.exports.length(), content="1")
debug_inspect(mod_.func_type_at(0).unwrap().params, content="[I32]")
debug_inspect(mod_.func_type_at(0).unwrap().results, content="[I64]")
}///|
let mod_ = @types.Module::simple([], [I32], [I32Const(42)], "answer")
///|
let text = @wat.render(mod_)///|
test "construct function subtypes for a module type section" {
let unary = func_subtype([I32], [I32])
let binary = func_subtype([I32, I32], [I32])
let mod_ = empty_module()
mod_.types.push(unary)
mod_.types.push(binary)
inspect(mod_.is_func_type(0), content="true")
inspect(mod_.is_func_type(1), content="true")
debug_inspect(mod_.func_type_at(1).unwrap().params, content="[I32, I32]")
}Reusable WebAssembly specification model for parsers, validators, and frontends