1use tokio::sync::oneshot;
2use tokio::task;
3
4async fn spawn_send() {
5 let (tx, rx) = oneshot::channel();
6
7 let task = tokio::spawn(async {
8 for _ in 0..10 {
9 task::yield_now().await;
10 }
11
12 tx.send("done").unwrap();
13 });
14
15 assert_eq!("done", rx.await.unwrap());
16 task.await.unwrap();
17}
18
19#[tokio::main(flavor = "current_thread")]
20async fn entry_point() {
21 spawn_send().await;
22}
23
24#[tokio::test]
25async fn test_macro() {
26 spawn_send().await;
27}
28
29#[test]
30fn main_macro() {
31 entry_point();
32}
33
34#[test]
35fn manual_rt() {
36 let rt = tokio::runtime::Builder::new_current_thread()
37 .build()
38 .unwrap();
39
40 rt.block_on(async { spawn_send().await });
41}
42