()
| 9 | #[tokio::test] |
| 10 | #[cfg_attr(miri, ignore)] |
| 11 | async fn smoke() -> Result<()> { |
| 12 | let component = r#" |
| 13 | (component |
| 14 | (core module $m |
| 15 | (func (export "thunk")) |
| 16 | (func (export "thunk-trap") unreachable) |
| 17 | ) |
| 18 | (core instance $i (instantiate $m)) |
| 19 | (func (export "thunk") |
| 20 | (canon lift (core func $i "thunk")) |
| 21 | ) |
| 22 | (func (export "thunk-trap") |
| 23 | (canon lift (core func $i "thunk-trap")) |
| 24 | ) |
| 25 | ) |
| 26 | "#; |
| 27 | |
| 28 | let engine = super::async_engine(); |
| 29 | let component = Component::new(&engine, component)?; |
| 30 | let mut store = Store::new(&engine, ()); |
| 31 | let instance = Linker::new(&engine) |
| 32 | .instantiate_async(&mut store, &component) |
| 33 | .await?; |
| 34 | |
| 35 | let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?; |
| 36 | |
| 37 | thunk.call_async(&mut store, ()).await?; |
| 38 | |
| 39 | let err = instance |
| 40 | .get_typed_func::<(), ()>(&mut store, "thunk-trap")? |
| 41 | .call_async(&mut store, ()) |
| 42 | .await |
| 43 | .unwrap_err(); |
| 44 | assert_eq!(err.downcast::<Trap>()?, Trap::UnreachableCodeReached); |
| 45 | |
| 46 | Ok(()) |
| 47 | } |
| 48 | |
| 49 | /// Handle an import function, created using component::Linker::func_wrap_async. |
| 50 | #[tokio::test] |
nothing calls this directly
no test coverage detected