js-sys: Add bindings for WebAssembly.instantiate

Part of #275
This commit is contained in:
Nick Fitzgerald
2018-09-06 14:35:45 -07:00
parent 8b5f5a7560
commit 021cbbab71
2 changed files with 25 additions and 0 deletions

View File

@ -172,6 +172,17 @@ fn webassembly_instance() {
assert!(Reflect::has(exports.as_ref(), &"exported_func".into()));
}
#[wasm_bindgen_test(async)]
fn instantiate_module() -> impl Future<Item = (), Error = JsValue> {
let module = WebAssembly::Module::new(&get_valid_wasm()).unwrap();
let imports = get_imports();
let p = WebAssembly::instantiate_module(&module, &imports);
JsFuture::from(p)
.map(|inst| {
assert!(inst.is_instance_of::<WebAssembly::Instance>());
})
}
#[wasm_bindgen_test]
fn memory_works() {
let obj = Object::new();