MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / linker_module_command

Function linker_module_command

tests/all/async_functions.rs:702–741  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

700#[tokio::test]
701#[cfg_attr(miri, ignore)]
702async fn linker_module_command() -> Result<()> {
703 let mut store = async_store();
704 let mut linker = Linker::new(store.engine());
705
706 let module1 = Module::new(
707 store.engine(),
708 r#"
709 (module
710 (global $g (mut i32) (i32.const 0))
711
712 (func (export "_start"))
713
714 (func (export "g") (result i32)
715 global.get $g
716 i32.const 1
717 global.set $g)
718 )
719 "#,
720 )?;
721
722 let module2 = Module::new(
723 store.engine(),
724 r#"
725 (module
726 (import "" "g" (func (result i32)))
727
728 (func (export "get") (result i32)
729 call 0)
730 )
731 "#,
732 )?;
733
734 linker.module_async(&mut store, "", &module1).await?;
735 let instance = linker.instantiate_async(&mut store, &module2).await?;
736 let f = instance.get_typed_func::<(), i32>(&mut store, "get")?;
737 assert_eq!(f.call_async(&mut store, ()).await?, 0);
738 assert_eq!(f.call_async(&mut store, ()).await?, 0);
739
740 Ok(())
741}
742
743#[tokio::test]
744#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
module_asyncMethod · 0.80
async_storeFunction · 0.70
newFunction · 0.50
engineMethod · 0.45
instantiate_asyncMethod · 0.45

Tested by

no test coverage detected