1 #![allow(unknown_lints, unexpected_cfgs)] 2 #![cfg(all(feature = "full", not(target_os = "wasi"), tokio_unstable))] 3 4 use tokio::task; 5 use tokio_test::task::spawn; 6 7 // `yield_now` is tested within the runtime in `rt_common`. 8 #[test] yield_now_outside_of_runtime()9fn yield_now_outside_of_runtime() { 10 let mut task = spawn(async { 11 task::yield_now().await; 12 }); 13 14 assert!(task.poll().is_pending()); 15 assert!(task.is_woken()); 16 assert!(task.poll().is_ready()); 17 } 18 19 #[tokio::test(flavor = "multi_thread")] yield_now_external_executor_and_block_in_place()20async fn yield_now_external_executor_and_block_in_place() { 21 let j = tokio::spawn(async { 22 task::block_in_place(|| futures::executor::block_on(task::yield_now())); 23 }); 24 j.await.unwrap(); 25 } 26