1 | #![cfg (all( |
2 | feature = "macros" , |
3 | feature = "rt-multi-thread" , |
4 | not(target_os = "wasi" ) |
5 | ))] |
6 | |
7 | #[tokio::main] |
8 | async fn basic_main() -> usize { |
9 | 1 |
10 | } |
11 | |
12 | #[tokio::main] |
13 | async fn generic_fun<T: Default>() -> T { |
14 | T::default() |
15 | } |
16 | |
17 | #[tokio::main] |
18 | async fn spawning() -> usize { |
19 | let join = tokio::spawn(async { 1 }); |
20 | join.await.unwrap() |
21 | } |
22 | |
23 | #[test] |
24 | fn main_with_spawn() { |
25 | assert_eq!(1, spawning()); |
26 | } |
27 | |
28 | #[test] |
29 | fn shell() { |
30 | assert_eq!(1, basic_main()); |
31 | assert_eq!(bool::default(), generic_fun::<bool>()) |
32 | } |
33 | |