()
| 3405 | |
| 3406 | #[tokio::test] |
| 3407 | async fn drop_call_async_future() -> Result<()> { |
| 3408 | let component = r#" |
| 3409 | (component |
| 3410 | (import "foo" (func $f)) |
| 3411 | (core module $m |
| 3412 | (func $f (import "" "foo")) |
| 3413 | (func (export "foo") call $f) |
| 3414 | ) |
| 3415 | (core func $f (canon lower (func $f))) |
| 3416 | (core instance $m (instantiate $m (with "" (instance |
| 3417 | (export "foo" (func $f)) |
| 3418 | )))) |
| 3419 | (func (export "foo") (canon lift (core func $m "foo"))) |
| 3420 | ) |
| 3421 | "#; |
| 3422 | |
| 3423 | let engine = &Engine::new(&Config::new())?; |
| 3424 | let component = Component::new(&engine, component)?; |
| 3425 | let mut store = Store::new(&engine, ()); |
| 3426 | let mut linker = Linker::new(&engine); |
| 3427 | linker.root().func_wrap_async("foo", |_, _: ()| { |
| 3428 | Box::new(async { |
| 3429 | tokio::task::yield_now().await; |
| 3430 | Ok(()) |
| 3431 | }) |
| 3432 | })?; |
| 3433 | let instance = linker.instantiate_async(&mut store, &component).await?; |
| 3434 | let foo = instance.get_typed_func::<(), ()>(&mut store, "foo")?; |
| 3435 | // Here we'll use `call_async` a few times but only poll each returned |
| 3436 | // future once. This will put the instance in a weird state but shouldn't |
| 3437 | // cause a panic. |
| 3438 | for _ in 0..5 { |
| 3439 | let mut future = std::pin::pin!(foo.call_async(&mut store, ())); |
| 3440 | if let std::task::Poll::Ready(result) = |
| 3441 | std::future::poll_fn(|cx| std::task::Poll::Ready(future.as_mut().poll(cx))).await |
| 3442 | { |
| 3443 | _ = result; |
| 3444 | } |
| 3445 | } |
| 3446 | |
| 3447 | Ok(()) |
| 3448 | } |
| 3449 | |
| 3450 | #[test] |
| 3451 | fn host_call_with_concurrency_disabled() -> Result<()> { |
nothing calls this directly
no test coverage detected