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

Function rust_panic_start_function

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

Source from the content-addressed store, hash-verified

478
479#[test]
480fn rust_panic_start_function() -> Result<()> {
481 let mut store = Store::<()>::default();
482 let binary = wat::parse_str(
483 r#"
484 (module $a
485 (import "" "" (func $foo))
486 (start $foo)
487 )
488 "#,
489 )?;
490
491 let module = Module::new(store.engine(), &binary)?;
492 let sig = FuncType::new(store.engine(), None, None);
493 let func = Func::new(&mut store, sig, |_, _, _| panic!("this is a panic"));
494 let err = panic::catch_unwind(AssertUnwindSafe(|| {
495 drop(Instance::new(&mut store, &module, &[func.into()]));
496 }))
497 .unwrap_err();
498 assert_eq!(err.downcast_ref::<&'static str>(), Some(&"this is a panic"));
499
500 let func = Func::wrap(&mut store, || -> () { panic!("this is another panic") });
501 let err = panic::catch_unwind(AssertUnwindSafe(|| {
502 drop(Instance::new(&mut store, &module, &[func.into()]));
503 }))
504 .unwrap_err();
505 assert_eq!(
506 err.downcast_ref::<&'static str>(),
507 Some(&"this is another panic")
508 );
509 Ok(())
510}
511
512#[test]
513fn mismatched_arguments() -> Result<()> {

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
newFunction · 0.50
dropFunction · 0.50
engineMethod · 0.45

Tested by

no test coverage detected