diff options
| author | Caleb Zulawski <caleb.zulawski@gmail.com> | 2021-02-13 00:41:58 -0500 |
|---|---|---|
| committer | Caleb Zulawski <caleb.zulawski@gmail.com> | 2021-02-15 18:22:24 -0500 |
| commit | b38d342d7727287c994aefcaa9b74c87e22e2dab (patch) | |
| tree | dc60cf837da670a72a7a26d54e4716505e6f2c1d | |
| parent | 223daea83ea60c725944e62815ffae2639a8d652 (diff) | |
| download | rust-b38d342d7727287c994aefcaa9b74c87e22e2dab.tar.gz rust-b38d342d7727287c994aefcaa9b74c87e22e2dab.zip | |
Simplify test creation
| -rw-r--r-- | crates/test_helpers/src/lib.rs | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs index 845dc1fcc44..77dafe38a10 100644 --- a/crates/test_helpers/src/lib.rs +++ b/crates/test_helpers/src/lib.rs @@ -186,44 +186,58 @@ pub fn test_binary_scalar_lhs_elementwise< } #[macro_export] -#[doc(hidden)] -macro_rules! test_lanes_impl { +macro_rules! test_lanes { { - fn $test:ident<const $lanes:ident: usize>() $body:tt - - $($name:ident => $lanes_lit:literal,)* + $(fn $test:ident<const $lanes:ident: usize>() $body:tt)* } => { - mod $test { - use super::*; - $( + $( + mod $test { + use super::*; + + fn implementation<const $lanes: usize>() $body + #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] - fn $name() { - const $lanes: usize = $lanes_lit; - $body + fn lanes_1() { + implementation::<1>(); } - )* - } - } -} -#[macro_export] -macro_rules! test_lanes { - { - $(fn $test:ident<const $lanes:ident: usize>() $body:tt)* - } => { - $( - $crate::test_lanes_impl! { - fn $test<const $lanes: usize>() $body - - lanes_1 => 1, - lanes_2 => 2, - lanes_4 => 4, - lanes_8 => 8, - lanes_16 => 16, - lanes_32 => 32, - lanes_64 => 64, - } + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn lanes_2() { + implementation::<2>(); + } + + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn lanes_4() { + implementation::<4>(); + } + + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn lanes_8() { + implementation::<8>(); + } + + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn lanes_16() { + implementation::<16>(); + } + + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn lanes_32() { + implementation::<32>(); + } + + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn lanes_64() { + implementation::<64>(); + } + } )* } } |
