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

Function new_from_signature

tests/all/host_funcs.rs:509–541  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

507#[test]
508#[cfg_attr(miri, ignore)]
509fn new_from_signature() -> Result<()> {
510 let engine = Engine::default();
511 let mut linker = Linker::new(&engine);
512
513 let ty = FuncType::new(&engine, None, None);
514 linker.func_new("", "f1", ty, |_, _, _| panic!())?;
515
516 let ty = FuncType::new(&engine, Some(ValType::I32), Some(ValType::F64));
517 linker.func_new("", "f2", ty, |_, _, _| panic!())?;
518
519 let mut store = Store::new(&engine, ());
520
521 let f = linker
522 .get(&mut store, "", "f1")
523 .unwrap()
524 .into_func()
525 .unwrap();
526 assert!(f.typed::<(), ()>(&store).is_ok());
527 assert!(f.typed::<(), i32>(&store).is_err());
528 assert!(f.typed::<i32, ()>(&store).is_err());
529
530 let f = linker
531 .get(&mut store, "", "f2")
532 .unwrap()
533 .into_func()
534 .unwrap();
535 assert!(f.typed::<(), ()>(&store).is_err());
536 assert!(f.typed::<(), i32>(&store).is_err());
537 assert!(f.typed::<i32, ()>(&store).is_err());
538 assert!(f.typed::<i32, f64>(&store).is_ok());
539
540 Ok(())
541}
542
543#[test]
544fn call_wrapped_func() -> Result<()> {

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
newFunction · 0.50
func_newMethod · 0.45
unwrapMethod · 0.45
into_funcMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected