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

Function test

tests/all/func.rs:1265–1291  ·  view source on GitHub ↗
(store: &mut Store<()>, t: T)

Source from the content-addressed store, hash-verified

1263#[cfg_attr(miri, ignore)]
1264fn wrap_multiple_results(config: &mut Config) -> wasmtime::Result<()> {
1265 fn test<T>(store: &mut Store<()>, t: T) -> wasmtime::Result<()>
1266 where
1267 T: WasmRet
1268 + WasmResults
1269 + PartialEq
1270 + Copy
1271 + std::fmt::Debug
1272 + EqualToValues
1273 + 'static
1274 + Send
1275 + Sync,
1276 {
1277 let f = Func::wrap(&mut *store, move || t);
1278 let mut results = vec![Val::I32(0); f.ty(&store).results().len()];
1279 assert_eq!(f.typed::<(), T>(&store)?.call(&mut *store, ())?, t);
1280 f.call(&mut *store, &[], &mut results)?;
1281 assert!(t.eq_values(&results));
1282
1283 let module = Module::new(store.engine(), &T::gen_wasm())?;
1284 let instance = Instance::new(&mut *store, &module, &[f.into()])?;
1285 let f = instance.get_func(&mut *store, "foo").unwrap();
1286
1287 assert_eq!(f.typed::<(), T>(&store)?.call(&mut *store, ())?, t);
1288 f.call(&mut *store, &[], &mut results)?;
1289 assert!(t.eq_values(&results));
1290 Ok(())
1291 }
1292
1293 let engine = Engine::new(&config)?;
1294 let mut store = Store::new(&engine, ());

Callers 6

wrap_multiple_resultsFunction · 0.70
mainFunction · 0.50
find_testsFunction · 0.50
mainFunction · 0.50
test_ptr_out_of_boundsFunction · 0.50

Calls 6

OkFunction · 0.85
newFunction · 0.50
callMethod · 0.45
engineMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45

Tested by 1

test_ptr_out_of_boundsFunction · 0.40