diff options
Diffstat (limited to 'test/src/test_func.rs')
| -rw-r--r-- | test/src/test_func.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/src/test_func.rs b/test/src/test_func.rs index 71fe365..666a99f 100644 --- a/test/src/test_func.rs +++ b/test/src/test_func.rs @@ -34,3 +34,35 @@ fn triple(x: i32) -> i32 { fn test_func_custom_feature() { assert_eq!(triple(3), 9); } + +#[cfg(feature = "metadata_async")] +#[test] +fn test_func_async_identity() { + let result = futures::executor::block_on(async { identity(42).await }); + assert_eq!(result, 42); +} + +#[cfg(feature = "metadata_async")] +#[test] +fn test_func_async_generic() { + let r = futures::executor::block_on(async { first(10, 20).await }); + assert_eq!(r, 10); +} + +#[might_be_async::func] +fn greet_async(name: &str) -> String { + format!("Hello, {name}!") +} + +#[cfg(not(feature = "metadata_async"))] +#[test] +fn test_func_sync_greet() { + assert_eq!(greet_async("world"), "Hello, world!"); +} + +#[cfg(feature = "metadata_async")] +#[test] +fn test_func_async_greet() { + let r = futures::executor::block_on(greet_async("world")); + assert_eq!(r, "Hello, world!"); +} |
