Skip to content

Commit b38d342

Browse files
committed
Simplify test creation
1 parent 223daea commit b38d342

File tree

1 file changed

+46
-32
lines changed

1 file changed

+46
-32
lines changed

crates/test_helpers/src/lib.rs

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -186,44 +186,58 @@ pub fn test_binary_scalar_lhs_elementwise<
186186
}
187187

188188
#[macro_export]
189-
#[doc(hidden)]
190-
macro_rules! test_lanes_impl {
189+
macro_rules! test_lanes {
191190
{
192-
fn $test:ident<const $lanes:ident: usize>() $body:tt
193-
194-
$($name:ident => $lanes_lit:literal,)*
191+
$(fn $test:ident<const $lanes:ident: usize>() $body:tt)*
195192
} => {
196-
mod $test {
197-
use super::*;
198-
$(
193+
$(
194+
mod $test {
195+
use super::*;
196+
197+
fn implementation<const $lanes: usize>() $body
198+
199199
#[test]
200200
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
201-
fn $name() {
202-
const $lanes: usize = $lanes_lit;
203-
$body
201+
fn lanes_1() {
202+
implementation::<1>();
204203
}
205-
)*
206-
}
207-
}
208-
}
209204

210-
#[macro_export]
211-
macro_rules! test_lanes {
212-
{
213-
$(fn $test:ident<const $lanes:ident: usize>() $body:tt)*
214-
} => {
215-
$(
216-
$crate::test_lanes_impl! {
217-
fn $test<const $lanes: usize>() $body
218-
219-
lanes_1 => 1,
220-
lanes_2 => 2,
221-
lanes_4 => 4,
222-
lanes_8 => 8,
223-
lanes_16 => 16,
224-
lanes_32 => 32,
225-
lanes_64 => 64,
226-
}
205+
#[test]
206+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
207+
fn lanes_2() {
208+
implementation::<2>();
209+
}
210+
211+
#[test]
212+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
213+
fn lanes_4() {
214+
implementation::<4>();
215+
}
216+
217+
#[test]
218+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
219+
fn lanes_8() {
220+
implementation::<8>();
221+
}
222+
223+
#[test]
224+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
225+
fn lanes_16() {
226+
implementation::<16>();
227+
}
228+
229+
#[test]
230+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
231+
fn lanes_32() {
232+
implementation::<32>();
233+
}
234+
235+
#[test]
236+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
237+
fn lanes_64() {
238+
implementation::<64>();
239+
}
240+
}
227241
)*
228242
}
229243
}

0 commit comments

Comments
 (0)