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

Function test_trap_return

tests/all/traps.rs:13–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12#[test]
13fn test_trap_return() -> Result<()> {
14 let mut store = Store::<()>::default();
15 let wat = r#"
16 (module
17 (func $hello (import "" "hello"))
18 (func (export "run") (call $hello))
19 )
20 "#;
21
22 let module = Module::new(store.engine(), wat)?;
23 let hello_type = FuncType::new(store.engine(), None, None);
24 let hello_func = Func::new(&mut store, hello_type, |_, _, _| bail!("test 123"));
25
26 let instance = Instance::new(&mut store, &module, &[hello_func.into()])?;
27 let run_func = instance.get_typed_func::<(), ()>(&mut store, "run")?;
28
29 let e = run_func.call(&mut store, ()).unwrap_err();
30 e.assert_contains("test 123");
31
32 assert!(
33 e.downcast_ref::<WasmBacktrace>().is_some(),
34 "error should contain a WasmBacktrace"
35 );
36
37 Ok(())
38}
39
40#[test]
41fn test_format_err_error_return() -> Result<()> {

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
assert_containsMethod · 0.80
newFunction · 0.50
engineMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected