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

Function ids_are_threaded_through

tests/all/component_model/bindgen.rs:1245–1270  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1243
1244 #[test]
1245 fn ids_are_threaded_through() -> Result<()> {
1246 let engine = implements_engine();
1247 let component = Component::new(&engine, COMPONENT)?;
1248 let mut linker = Linker::new(&engine);
1249 named_imports::demo::pkg::store::add_to_linker::<_, HasSelf<MyHost>>(
1250 &mut linker,
1251 &component,
1252 |name| match name {
1253 "a" => Ok(MyId(1)),
1254 "b" => Ok(MyId(2)),
1255 other => wasmtime::bail!("unexpected import: {other}"),
1256 },
1257 |s| s,
1258 )?;
1259 let mut store = Store::new(&engine, MyHost::default());
1260 let cache = Cache::instantiate(&mut store, &component, &linker)?;
1261
1262 cache.call_run(&mut store)?;
1263
1264 let calls = &store.data().calls;
1265 assert!(calls.contains(&(1, "set")), "calls: {calls:?}");
1266 assert!(calls.contains(&(2, "set")), "calls: {calls:?}");
1267 assert!(calls.contains(&(1, "get")), "calls: {calls:?}");
1268 assert!(calls.contains(&(2, "get")), "calls: {calls:?}");
1269 Ok(())
1270 }
1271
1272 #[test]
1273 fn lookup_error_is_propagated() -> Result<()> {

Callers

nothing calls this directly

Calls 7

implements_engineFunction · 0.85
OkFunction · 0.85
call_runMethod · 0.80
MyIdClass · 0.70
newFunction · 0.50
instantiateFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected