diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-23 08:08:33 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-23 14:01:45 +0800 |
| commit | 68a652ed2f51d366bb8033497e6dfe545895410e (patch) | |
| tree | d463833846248410733e196a0939c59cd67ca8a2 /test/src/test_func.rs | |
feat: scaffold crate structure and implement core macros
Add the project skeleton, LICENSE files, README, Makefile, doc
examples, and the initial implementation of `#[func]`, `invoke!`,
and `select!` procedural macros.
Diffstat (limited to 'test/src/test_func.rs')
| -rw-r--r-- | test/src/test_func.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/src/test_func.rs b/test/src/test_func.rs new file mode 100644 index 0000000..71fe365 --- /dev/null +++ b/test/src/test_func.rs @@ -0,0 +1,36 @@ +#[might_be_async::func] +fn identity(x: i32) -> i32 { + x +} + +#[cfg(not(feature = "metadata_async"))] +#[test] +fn test_func_identity() { + assert_eq!(identity(42), 42); +} + +#[might_be_async::func] +fn first<T: PartialEq + Clone>(a: T, _b: T) -> T +where + T: std::fmt::Debug, +{ + a.clone() +} + +#[cfg(not(feature = "metadata_async"))] +#[test] +fn test_func_generic() { + assert_eq!(first(1, 2), 1); + assert_eq!(first("a", "b"), "a"); +} + +#[might_be_async::func("custom_ft")] +fn triple(x: i32) -> i32 { + x * 3 +} + +#[cfg(not(feature = "metadata_async"))] +#[test] +fn test_func_custom_feature() { + assert_eq!(triple(3), 9); +} |
