1+ /// Implements a test on a unary operation using proptest.
2+ ///
3+ /// Compares the vector operation to the equivalent scalar operation.
14#[ macro_export]
25macro_rules! impl_unary_op_test {
36 { $vector: ty, $scalar: ty, $trait: ident :: $fn: ident, $scalar_fn: expr } => {
@@ -16,6 +19,9 @@ macro_rules! impl_unary_op_test {
1619 } ;
1720}
1821
22+ /// Implements a test on a binary operation using proptest.
23+ ///
24+ /// Compares the vector operation to the equivalent scalar operation.
1925#[ macro_export]
2026macro_rules! impl_binary_op_test {
2127 { $vector: ty, $scalar: ty, $trait: ident :: $fn: ident, $trait_assign: ident :: $fn_assign: ident, $scalar_fn: expr } => {
@@ -70,6 +76,12 @@ macro_rules! impl_binary_op_test {
7076 } ;
7177}
7278
79+ /// Implements a test on a binary operation using proptest.
80+ ///
81+ /// Like `impl_binary_op_test`, but allows providing a function for rejecting particular inputs
82+ /// (like the `proptest_assume` macro).
83+ ///
84+ /// Compares the vector operation to the equivalent scalar operation.
7385#[ macro_export]
7486macro_rules! impl_binary_checked_op_test {
7587 { $vector: ty, $scalar: ty, $trait: ident :: $fn: ident, $trait_assign: ident :: $fn_assign: ident, $scalar_fn: expr, $check_fn: expr } => {
@@ -124,6 +136,7 @@ macro_rules! impl_binary_checked_op_test {
124136 } ;
125137}
126138
139+ /// Implement tests for signed integers.
127140#[ macro_export]
128141macro_rules! impl_signed_tests {
129142 { $vector: ident, $scalar: tt } => {
@@ -191,6 +204,8 @@ macro_rules! impl_signed_tests {
191204 impl_binary_op_test!( Vector <LANES >, Scalar , Add :: add, AddAssign :: add_assign, Scalar :: wrapping_add) ;
192205 impl_binary_op_test!( Vector <LANES >, Scalar , Sub :: sub, SubAssign :: sub_assign, Scalar :: wrapping_sub) ;
193206 impl_binary_op_test!( Vector <LANES >, Scalar , Mul :: mul, MulAssign :: mul_assign, Scalar :: wrapping_mul) ;
207+
208+ // Exclude Div and Rem panicking cases
194209 impl_binary_checked_op_test!( Vector <LANES >, Scalar , Div :: div, DivAssign :: div_assign, Scalar :: wrapping_div, |x, y| y != 0 && !( x == Scalar :: MIN && y == -1 ) ) ;
195210 impl_binary_checked_op_test!( Vector <LANES >, Scalar , Rem :: rem, RemAssign :: rem_assign, Scalar :: wrapping_rem, |x, y| y != 0 && !( x == Scalar :: MIN && y == -1 ) ) ;
196211
@@ -202,6 +217,7 @@ macro_rules! impl_signed_tests {
202217 }
203218}
204219
220+ /// Implement tests for unsigned integers.
205221#[ macro_export]
206222macro_rules! impl_unsigned_tests {
207223 { $vector: ident, $scalar: tt } => {
@@ -220,6 +236,8 @@ macro_rules! impl_unsigned_tests {
220236 impl_binary_op_test!( Vector <LANES >, Scalar , Add :: add, AddAssign :: add_assign, Scalar :: wrapping_add) ;
221237 impl_binary_op_test!( Vector <LANES >, Scalar , Sub :: sub, SubAssign :: sub_assign, Scalar :: wrapping_sub) ;
222238 impl_binary_op_test!( Vector <LANES >, Scalar , Mul :: mul, MulAssign :: mul_assign, Scalar :: wrapping_mul) ;
239+
240+ // Exclude Div and Rem panicking cases
223241 impl_binary_checked_op_test!( Vector <LANES >, Scalar , Div :: div, DivAssign :: div_assign, Scalar :: wrapping_div, |_, y| y != 0 ) ;
224242 impl_binary_checked_op_test!( Vector <LANES >, Scalar , Rem :: rem, RemAssign :: rem_assign, Scalar :: wrapping_rem, |_, y| y != 0 ) ;
225243
@@ -231,6 +249,7 @@ macro_rules! impl_unsigned_tests {
231249 }
232250}
233251
252+ /// Implement tests for floating point numbers.
234253#[ macro_export]
235254macro_rules! impl_float_tests {
236255 { $vector: ident, $scalar: tt, $int_scalar: tt } => {
0 commit comments