use std::time::Duration;
use tokio::time::sleep;
mod support;
use support::{assert_tasks, spawn_named, ExpectedTask};
#[test]
#[allow(clippy::async_yields_async)]
fn child_polls_dont_count_towards_parent_polls() {
let expected_tasks = vec![
ExpectedTask::default()
.match_name("parent".into())
.expect_polls(2),
ExpectedTask::default()
.match_name("child".into())
.expect_polls(3),
];
let future = async {
let child_join_handle = spawn_named("parent", async {
spawn_named("child", async {
sleep(Duration::ZERO).await;
})
})
.await
.expect("joining parent failed");
child_join_handle.await.expect("joining child failed");
};
assert_tasks(expected_tasks, future);
}