1 #[cfg(all(tokio_unstable, feature = "tracing"))]
2 mod tests {
3     use std::rc::Rc;
4     use tokio::{
5         task::{Builder, LocalSet},
6         test,
7     };
8 
9     #[test]
spawn_with_name()10     async fn spawn_with_name() {
11         let result = Builder::new()
12             .name("name")
13             .spawn(async { "task executed" })
14             .await;
15 
16         assert_eq!(result.unwrap(), "task executed");
17     }
18 
19     #[test]
spawn_blocking_with_name()20     async fn spawn_blocking_with_name() {
21         let result = Builder::new()
22             .name("name")
23             .spawn_blocking(|| "task executed")
24             .await;
25 
26         assert_eq!(result.unwrap(), "task executed");
27     }
28 
29     #[test]
spawn_local_with_name()30     async fn spawn_local_with_name() {
31         let unsend_data = Rc::new("task executed");
32         let result = LocalSet::new()
33             .run_until(async move {
34                 Builder::new()
35                     .name("name")
36                     .spawn_local(async move { unsend_data })
37                     .await
38             })
39             .await;
40 
41         assert_eq!(*result.unwrap(), "task executed");
42     }
43 
44     #[test]
spawn_without_name()45     async fn spawn_without_name() {
46         let result = Builder::new().spawn(async { "task executed" }).await;
47 
48         assert_eq!(result.unwrap(), "task executed");
49     }
50 
51     #[test]
spawn_blocking_without_name()52     async fn spawn_blocking_without_name() {
53         let result = Builder::new().spawn_blocking(|| "task executed").await;
54 
55         assert_eq!(result.unwrap(), "task executed");
56     }
57 
58     #[test]
spawn_local_without_name()59     async fn spawn_local_without_name() {
60         let unsend_data = Rc::new("task executed");
61         let result = LocalSet::new()
62             .run_until(async move { Builder::new().spawn_local(async move { unsend_data }).await })
63             .await;
64 
65         assert_eq!(*result.unwrap(), "task executed");
66     }
67 }
68