diff --git a/fidget/src/core/eval/test/float_slice.rs b/fidget/src/core/eval/test/float_slice.rs index 64928d72..b450ac85 100644 --- a/fidget/src/core/eval/test/float_slice.rs +++ b/fidget/src/core/eval/test/float_slice.rs @@ -439,40 +439,11 @@ where } } - pub fn test_f_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } - pub fn test_binary() { Self::test_binary_reg_reg::(); Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_f_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } } #[macro_export] @@ -493,7 +464,19 @@ macro_rules! float_slice_tests { $crate::float_slice_test!(test_f_var, $t); $crate::float_slice_test!(test_f_sin, $t); $crate::float_slice_test!(test_f_stress, $t); - $crate::float_slice_test!(test_f_unary_ops, $t); - $crate::float_slice_test!(test_f_binary_ops, $t); + + mod f_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::float_slice::TestFloatSlice::<$t> + ); + } + + mod f_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::float_slice::TestFloatSlice::<$t> + ); + } }; } diff --git a/fidget/src/core/eval/test/grad_slice.rs b/fidget/src/core/eval/test/grad_slice.rs index 242a00a3..2969fcdb 100644 --- a/fidget/src/core/eval/test/grad_slice.rs +++ b/fidget/src/core/eval/test/grad_slice.rs @@ -699,40 +699,11 @@ where } } - pub fn test_g_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } - pub fn test_binary() { Self::test_binary_reg_reg::(); Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_g_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } } #[macro_export] @@ -764,7 +735,19 @@ macro_rules! grad_slice_tests { $crate::grad_test!(test_g_recip, $t); $crate::grad_test!(test_g_var, $t); $crate::grad_test!(test_g_stress, $t); - $crate::grad_test!(test_g_unary_ops, $t); - $crate::grad_test!(test_g_binary_ops, $t); + + mod g_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::grad_slice::TestGradSlice::<$t> + ); + } + + mod g_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::grad_slice::TestGradSlice::<$t> + ); + } }; } diff --git a/fidget/src/core/eval/test/interval.rs b/fidget/src/core/eval/test/interval.rs index c5e5003f..349fe6c3 100644 --- a/fidget/src/core/eval/test/interval.rs +++ b/fidget/src/core/eval/test/interval.rs @@ -889,40 +889,11 @@ where } } - pub fn test_i_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } - pub fn test_binary() { Self::test_binary_reg_reg::(); Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_i_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } } #[macro_export] @@ -957,7 +928,19 @@ macro_rules! interval_tests { $crate::interval_test!(test_i_simplify, $t); $crate::interval_test!(test_i_var, $t); $crate::interval_test!(test_i_stress, $t); - $crate::interval_test!(test_i_unary_ops, $t); - $crate::interval_test!(test_i_binary_ops, $t); + + mod i_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::interval::TestInterval::<$t> + ); + } + + mod i_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::interval::TestInterval::<$t> + ); + } }; } diff --git a/fidget/src/core/eval/test/mod.rs b/fidget/src/core/eval/test/mod.rs index 4eda05e0..7609bba2 100644 --- a/fidget/src/core/eval/test/mod.rs +++ b/fidget/src/core/eval/test/mod.rs @@ -157,7 +157,7 @@ macro_rules! declare_canonical_binary_full { } #[allow(non_camel_case_types)] -mod canonical { +pub mod canonical { use super::*; declare_canonical_unary!(Context::neg, |a| -a); @@ -205,3 +205,54 @@ mod canonical { } ); } + +#[macro_export] +macro_rules! one_unary_test { + ($tester:ty, $i:ident) => { + #[test] + fn $i() { + <$tester>::test_unary::<$crate::eval::test::canonical::$i>() + } + }; +} + +#[macro_export] +macro_rules! one_binary_test { + ($tester:ty, $i:ident) => { + #[test] + fn $i() { + <$tester>::test_binary::<$crate::eval::test::canonical::$i>() + } + }; +} + +#[macro_export] +macro_rules! all_unary_tests { + ($tester:ty) => { + $crate::one_unary_test!($tester, neg); + $crate::one_unary_test!($tester, recip); + $crate::one_unary_test!($tester, abs); + $crate::one_unary_test!($tester, sin); + $crate::one_unary_test!($tester, cos); + $crate::one_unary_test!($tester, tan); + $crate::one_unary_test!($tester, asin); + $crate::one_unary_test!($tester, acos); + $crate::one_unary_test!($tester, atan); + $crate::one_unary_test!($tester, exp); + $crate::one_unary_test!($tester, ln); + $crate::one_unary_test!($tester, square); + $crate::one_unary_test!($tester, sqrt); + }; +} + +#[macro_export] +macro_rules! all_binary_tests { + ($tester:ty) => { + $crate::one_binary_test!($tester, add); + $crate::one_binary_test!($tester, sub); + $crate::one_binary_test!($tester, mul); + $crate::one_binary_test!($tester, div); + $crate::one_binary_test!($tester, min); + $crate::one_binary_test!($tester, max); + }; +} diff --git a/fidget/src/core/eval/test/point.rs b/fidget/src/core/eval/test/point.rs index 9a9cb454..dc2ca221 100644 --- a/fidget/src/core/eval/test/point.rs +++ b/fidget/src/core/eval/test/point.rs @@ -556,35 +556,6 @@ where Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_p_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } - - pub fn test_p_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } } #[macro_export] @@ -611,7 +582,19 @@ macro_rules! point_tests { $crate::point_test!(test_var, $t); $crate::point_test!(test_basic, $t); $crate::point_test!(test_p_stress, $t); - $crate::point_test!(test_p_unary_ops, $t); - $crate::point_test!(test_p_binary_ops, $t); + + mod p_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::point::TestPoint::<$t> + ); + } + + mod p_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::point::TestPoint::<$t> + ); + } }; }