diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-23 23:23:56 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-23 23:23:56 +0800 |
| commit | f9f879e488a62eba9c54c8e713cc94cc9f20e96e (patch) | |
| tree | e311493f8c491f5a14bedde9e54f3c90c0a3dbdb /test/src/test_select.rs | |
| parent | ee4a0ad75a52960ce674098986ce2b7be1cfe4e7 (diff) | |
feat(config): refactor default feature name parsing
Diffstat (limited to 'test/src/test_select.rs')
| -rw-r--r-- | test/src/test_select.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/src/test_select.rs b/test/src/test_select.rs index 2cf3bfe..901ee35 100644 --- a/test/src/test_select.rs +++ b/test/src/test_select.rs @@ -90,3 +90,28 @@ fn test_select_metadata_two_not() { let r = might_be_async::select! { ! => { 70 } else ! => { 80 } }; assert_eq!(r, 80); } + +#[might_be_async::func] +fn pick(toggle: bool) -> &'static str { + might_be_async::select! { "metadata_async" => { + if toggle { "async_on_a" } else { "async_on_b" } + } else ! => { + if toggle { "sync_a" } else { "sync_b" } + }} +} + +#[cfg(not(feature = "metadata_async"))] +#[test] +fn test_select_inside_func_sync() { + assert_eq!(pick(true), "sync_a"); + assert_eq!(pick(false), "sync_b"); +} + +#[cfg(feature = "metadata_async")] +#[test] +fn test_select_inside_func_async() { + let r = futures::executor::block_on(async { pick(true).await }); + assert_eq!(r, "async_on_a"); + let r = futures::executor::block_on(async { pick(false).await }); + assert_eq!(r, "async_on_b"); +} |
