()
| 646 | #[tokio::test] |
| 647 | #[cfg_attr(miri, ignore)] |
| 648 | async fn caught_exception_events() -> wasmtime::Result<()> { |
| 649 | let _ = env_logger::try_init(); |
| 650 | |
| 651 | let (module, mut store) = get_module_and_store( |
| 652 | |config| { |
| 653 | config.wasm_exceptions(true); |
| 654 | }, |
| 655 | r#" |
| 656 | (module |
| 657 | (tag $t (param i32)) |
| 658 | (func (export "main") |
| 659 | (block $b (result i32) |
| 660 | (try_table (catch $t $b) |
| 661 | call 1) |
| 662 | i32.const 0) |
| 663 | drop) |
| 664 | (func |
| 665 | (local $i i32) |
| 666 | (local.set $i (i32.const 100)) |
| 667 | (throw $t (i32.const 42)))) |
| 668 | "#, |
| 669 | )?; |
| 670 | |
| 671 | debug_event_checker!( |
| 672 | D, store, |
| 673 | { 0 ; |
| 674 | wasmtime::DebugEvent::Exception(e) => { |
| 675 | assert_eq!(e.field(&mut store, 0).unwrap().unwrap_i32(), 42); |
| 676 | let stack = store.debug_exit_frames().next().unwrap(); |
| 677 | assert_eq!(stack.num_locals(&mut store).unwrap(), 1); |
| 678 | assert_eq!(stack.local(&mut store, 0).unwrap().unwrap_i32(), 100); |
| 679 | let stack = stack.parent(&mut store).unwrap().unwrap(); |
| 680 | let stack = stack.parent(&mut store).unwrap(); |
| 681 | assert!(stack.is_none()); |
| 682 | } |
| 683 | } |
| 684 | ); |
| 685 | |
| 686 | let (handler, counter) = D::new_and_counter(); |
| 687 | store.set_debug_handler(handler); |
| 688 | |
| 689 | let instance = Instance::new_async(&mut store, &module, &[]).await?; |
| 690 | let func = instance.get_func(&mut store, "main").unwrap(); |
| 691 | let mut results = []; |
| 692 | func.call_async(&mut store, &[], &mut results).await?; |
| 693 | assert_eq!(counter.load(Ordering::Relaxed), 1); |
| 694 | |
| 695 | Ok(()) |
| 696 | } |
| 697 | |
| 698 | #[tokio::test] |
| 699 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected