Fix MulAssign typo in tests, move panic tests

This commit is contained in:
Caleb Zulawski 2021-02-13 15:42:04 -05:00
parent 0ec3ecfab1
commit 714ad639b3
34 changed files with 129 additions and 592 deletions

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_float_tests! { SimdF32, f32, i32 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_float_tests! { SimdF64, f64, i64 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_signed_tests! { SimdI128, i128 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_signed_tests! { SimdI16, i16 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_signed_tests! { SimdI32, i32 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_signed_tests! { SimdI64, i64 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_signed_tests! { SimdI8, i8 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_signed_tests! { SimdIsize, isize }

View File

@ -0,0 +1 @@
mod mask_ops_impl;

View File

@ -1 +0,0 @@
mod ops_impl;

View File

@ -1,101 +0,0 @@
macro_rules! int_tests {
{ $vector:ident, $scalar:ident } => {
#[cfg(test)]
mod $vector {
use super::*;
use helpers::lanewise::*;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
#[cfg(target_arch = "wasm32")]
wasm_bindgen_test_configure!(run_in_browser);
// TODO impl this as an associated fn on vectors
fn from_slice(slice: &[$scalar]) -> core_simd::$vector {
let mut value = core_simd::$vector::default();
let value_slice: &mut [_] = value.as_mut();
value_slice.copy_from_slice(&slice[0..value_slice.len()]);
value
}
const A: [$scalar; 64] = [
7, 7, 7, 7, -7, -7, -7, -7,
6, 6, 6, 6, -6, -6, -6, -6,
5, 5, 5, 5, -5, -5, -5, -5,
4, 4, 4, 4, -4, -4, -4, -4,
3, 3, 3, 3, -3, -3, -3, -3,
2, 2, 2, 2, -2, -2, -2, -2,
1, 1, 1, 1, -1, -1, -1, -1,
0, 0, 0, 0, 0, 0, 0, 0,
];
const B: [$scalar; 64] = [
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
-1, -2, -3, -4, -5, -6, -7, -8,
-1, -2, -3, -4, -5, -6, -7, -8,
-1, -2, -3, -4, -5, -6, -7, -8,
-1, -2, -3, -4, -5, -6, -7, -8,
];
#[test]
#[should_panic]
fn div_min_panics() {
let a = from_slice(&vec![$scalar::MIN; 64]);
let b = from_slice(&vec![-1; 64]);
let _ = a / b;
}
#[test]
#[should_panic]
fn div_by_all_zeros_panics() {
let a = from_slice(&A);
let b = from_slice(&vec![0 ; 64]);
let _ = a / b;
}
#[test]
#[should_panic]
fn div_by_one_zero_panics() {
let a = from_slice(&A);
let mut b = from_slice(&B);
b[0] = 0 as _;
let _ = a / b;
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn div_min_neg_one_no_panic() {
let a = from_slice(&A);
let b = from_slice(&vec![-1; 64]);
let _ = a / b;
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rem_min_neg_one_no_panic() {
let a = from_slice(&A);
let b = from_slice(&vec![-1; 64]);
let _ = a % b;
}
#[test]
#[should_panic]
fn rem_min_panic() {
let a = from_slice(&vec![$scalar::MIN; 64]);
let b = from_slice(&vec![-1 ; 64]);
let _ = a % b;
}
#[test]
#[should_panic]
fn rem_min_zero_panic() {
let a = from_slice(&A);
let b = from_slice(&vec![0 ; 64]);
let _ = a % b;
}
}
}
}

View File

@ -1,4 +0,0 @@
use super::helpers;
uint_tests! { u128x2, u128 }
uint_tests! { u128x4, u128 }

View File

@ -1,6 +0,0 @@
use super::helpers;
uint_tests! { u16x4, u16 }
uint_tests! { u16x8, u16 }
uint_tests! { u16x16, u16 }
uint_tests! { u16x32, u16 }

View File

@ -1,6 +0,0 @@
use super::helpers;
uint_tests! { u32x2, u32 }
uint_tests! { u32x4, u32 }
uint_tests! { u32x8, u32 }
uint_tests! { u32x16, u32 }

View File

@ -1,5 +0,0 @@
use super::helpers;
uint_tests! { u64x2, u64 }
uint_tests! { u64x4, u64 }
uint_tests! { u64x8, u64 }

View File

@ -1,6 +0,0 @@
use super::helpers;
uint_tests! { u8x8, u8 }
uint_tests! { u8x16, u8 }
uint_tests! { u8x32, u8 }
uint_tests! { u8x64, u8 }

View File

@ -1,428 +0,0 @@
macro_rules! uint_tests {
{ $vector:ident, $scalar:ident } => {
#[cfg(test)]
mod $vector {
use super::*;
use helpers::lanewise::*;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
#[cfg(target_arch = "wasm32")]
wasm_bindgen_test_configure!(run_in_browser);
// TODO impl this as an associated fn on vectors
fn from_slice(slice: &[$scalar]) -> core_simd::$vector {
let mut value = core_simd::$vector::default();
let value_slice: &mut [_] = value.as_mut();
value_slice.copy_from_slice(&slice[0..value_slice.len()]);
value
}
const A: [$scalar; 64] = [
16, 16, 16, 16, 16, 16, 16, 16,
14, 14, 14, 14, 14, 14, 14, 14,
12, 12, 12, 12, 12, 12, 12, 12,
10, 10, 10, 10, 10, 10, 10, 10,
8, 8, 8, 8, 8, 8, 8, 8,
6, 6, 6, 6, 6, 6, 7, 8,
4, 4, 4, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
];
const B: [$scalar; 64] = [
1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
];
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn add() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Add::add);
assert_biteq!(a + b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn add_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Add::add);
a += b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn add_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Add::add);
assert_biteq!(a + b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn add_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::Add::add);
assert_biteq!(a + b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn add_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Add::add);
a += b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn sub() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Sub::sub);
assert_biteq!(a - b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn sub_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Sub::sub);
a -= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn sub_scalar_rhs() {
let a = from_slice(&A);
let b = 1;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Sub::sub);
assert_biteq!(a - b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn sub_scalar_lhs() {
let a = 40;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::Sub::sub);
assert_biteq!(a - b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn sub_assign_scalar() {
let mut a = from_slice(&A);
let b = 1;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Sub::sub);
a -= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Mul::mul);
assert_biteq!(a * b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Mul::mul);
a *= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Mul::mul);
assert_biteq!(a * b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::Mul::mul);
assert_biteq!(a * b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Mul::mul);
a *= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn div() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Div::div);
assert_biteq!(a / b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn div_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Div::div);
a /= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn div_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Div::div);
assert_biteq!(a / b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn div_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::Div::div);
assert_biteq!(a / b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn div_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Div::div);
a /= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rem() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Rem::rem);
assert_biteq!(a % b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rem_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::Rem::rem);
a %= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rem_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Rem::rem);
assert_biteq!(a % b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rem_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::Rem::rem);
assert_biteq!(a % b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rem_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::Rem::rem);
a %= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitand() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::BitAnd::bitand);
assert_biteq!(a & b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitand_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::BitAnd::bitand);
a &= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitand_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::BitAnd::bitand);
assert_biteq!(a & b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitand_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::BitAnd::bitand);
assert_biteq!(a & b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitand_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::BitAnd::bitand);
a &= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitor() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::BitOr::bitor);
assert_biteq!(a | b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitor_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::BitOr::bitor);
a |= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitor_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::BitOr::bitor);
assert_biteq!(a | b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitor_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::BitOr::bitor);
assert_biteq!(a | b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitor_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::BitOr::bitor);
a |= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitxor() {
let a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::BitXor::bitxor);
assert_biteq!(a ^ b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitxor_assign() {
let mut a = from_slice(&A);
let b = from_slice(&B);
let expected = apply_binary_lanewise(a, b, core::ops::BitXor::bitxor);
a ^= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitxor_scalar_rhs() {
let a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::BitXor::bitxor);
assert_biteq!(a ^ b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitxor_scalar_lhs() {
let a = 5;
let b = from_slice(&B);
let expected = apply_binary_scalar_lhs_lanewise(a, b, core::ops::BitXor::bitxor);
assert_biteq!(a ^ b, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn bitxor_assign_scalar() {
let mut a = from_slice(&A);
let b = 5;
let expected = apply_binary_scalar_rhs_lanewise(a, b, core::ops::BitXor::bitxor);
a ^= b;
assert_biteq!(a, expected);
}
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn not() {
let v = from_slice(&A);
let expected = apply_unary_lanewise(v, core::ops::Not::not);
assert_biteq!(!v, expected);
}
}
}
}

View File

@ -1,5 +0,0 @@
use super::helpers;
uint_tests! { usizex2, usize }
uint_tests! { usizex4, usize }
uint_tests! { usizex8, usize }

View File

@ -141,6 +141,53 @@ macro_rules! impl_signed_tests {
}
}
test_helpers::test_lanes_panic! {
fn div_min_overflow_panics<const LANES: usize>() {
let a = Vector::<LANES>::splat(Scalar::MIN);
let b = Vector::<LANES>::splat(-1);
let _ = a / b;
}
fn div_by_all_zeros_panics<const LANES: usize>() {
let a = Vector::<LANES>::splat(42);
let b = Vector::<LANES>::splat(0);
let _ = a / b;
}
fn div_by_one_zero_panics<const LANES: usize>() {
let a = Vector::<LANES>::splat(42);
let mut b = Vector::<LANES>::splat(21);
b[0] = 0 as _;
let _ = a / b;
}
fn rem_min_overflow_panic<const LANES: usize>() {
let a = Vector::<LANES>::splat(Scalar::MIN);
let b = Vector::<LANES>::splat(-1);
let _ = a % b;
}
fn rem_zero_panic<const LANES: usize>() {
let a = Vector::<LANES>::splat(42);
let b = Vector::<LANES>::splat(0);
let _ = a % b;
}
}
test_helpers::test_lanes! {
fn div_neg_one_no_panic<const LANES: usize>() {
let a = Vector::<LANES>::splat(42);
let b = Vector::<LANES>::splat(-1);
let _ = a / b;
}
fn rem_neg_one_no_panic<const LANES: usize>() {
let a = Vector::<LANES>::splat(42);
let b = Vector::<LANES>::splat(-1);
let _ = a % b;
}
}
impl_binary_op_test!(Vector<LANES>, Scalar, Add::add, AddAssign::add_assign, Scalar::wrapping_add);
impl_binary_op_test!(Vector<LANES>, Scalar, Sub::sub, SubAssign::sub_assign, Scalar::wrapping_sub);
impl_binary_op_test!(Vector<LANES>, Scalar, Mul::mul, MulAssign::mul_assign, Scalar::wrapping_mul);
@ -162,6 +209,14 @@ macro_rules! impl_unsigned_tests {
type Vector<const LANES: usize> = core_simd::$vector<LANES>;
type Scalar = $scalar;
test_helpers::test_lanes_panic! {
fn rem_zero_panic<const LANES: usize>() {
let a = Vector::<LANES>::splat(42);
let b = Vector::<LANES>::splat(0);
let _ = a % b;
}
}
impl_binary_op_test!(Vector<LANES>, Scalar, Add::add, AddAssign::add_assign, Scalar::wrapping_add);
impl_binary_op_test!(Vector<LANES>, Scalar, Sub::sub, SubAssign::sub_assign, Scalar::wrapping_sub);
impl_binary_op_test!(Vector<LANES>, Scalar, Mul::mul, MulAssign::mul_assign, Scalar::wrapping_mul);
@ -187,7 +242,7 @@ macro_rules! impl_float_tests {
impl_unary_op_test!(Vector<LANES>, Scalar, Neg::neg);
impl_binary_op_test!(Vector<LANES>, Scalar, Add::add, AddAssign::add_assign);
impl_binary_op_test!(Vector<LANES>, Scalar, Sub::sub, SubAssign::sub_assign);
impl_binary_op_test!(Vector<LANES>, Scalar, Mul::mul, SubAssign::sub_assign);
impl_binary_op_test!(Vector<LANES>, Scalar, Mul::mul, MulAssign::mul_assign);
impl_binary_op_test!(Vector<LANES>, Scalar, Div::div, DivAssign::div_assign);
impl_binary_op_test!(Vector<LANES>, Scalar, Rem::rem, RemAssign::rem_assign);

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_unsigned_tests! { SimdU128, u128 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_unsigned_tests! { SimdU16, u16 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_unsigned_tests! { SimdU32, u32 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_unsigned_tests! { SimdU64, u64 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_unsigned_tests! { SimdU8, u8 }

View File

@ -1,4 +1,3 @@
#[macro_use]
#[path = "ops_macros.rs"]
mod macros;
mod ops_macros;
impl_unsigned_tests! { SimdUsize, usize }

View File

@ -280,4 +280,61 @@ macro_rules! test_lanes {
}
)*
}
}
}
#[macro_export]
macro_rules! test_lanes_panic {
{
$(fn $test:ident<const $lanes:ident: usize>() $body:tt)*
} => {
$(
mod $test {
use super::*;
fn implementation<const $lanes: usize>() $body
#[test]
#[should_panic]
fn lanes_1() {
implementation::<1>();
}
#[test]
#[should_panic]
fn lanes_2() {
implementation::<2>();
}
#[test]
#[should_panic]
fn lanes_4() {
implementation::<4>();
}
#[test]
#[should_panic]
fn lanes_8() {
implementation::<8>();
}
#[test]
#[should_panic]
fn lanes_16() {
implementation::<16>();
}
#[test]
#[should_panic]
fn lanes_32() {
implementation::<32>();
}
#[test]
#[should_panic]
fn lanes_64() {
implementation::<64>();
}
}
)*
}
}