aboutsummaryrefslogtreecommitdiff
path: root/test/src/test_func.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-23 23:23:56 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-23 23:23:56 +0800
commitf9f879e488a62eba9c54c8e713cc94cc9f20e96e (patch)
treee311493f8c491f5a14bedde9e54f3c90c0a3dbdb /test/src/test_func.rs
parentee4a0ad75a52960ce674098986ce2b7be1cfe4e7 (diff)
feat(config): refactor default feature name parsing
Diffstat (limited to 'test/src/test_func.rs')
-rw-r--r--test/src/test_func.rs32
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!");
+}