Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do bulk testing in parallel #39

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 14 additions & 31 deletions fidget/src/core/eval/test/float_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,40 +439,11 @@ where
}
}

pub fn test_f_unary_ops() {
use super::canonical::*;

Self::test_unary::<neg>();
Self::test_unary::<recip>();
Self::test_unary::<abs>();
Self::test_unary::<sin>();
Self::test_unary::<cos>();
Self::test_unary::<tan>();
Self::test_unary::<asin>();
Self::test_unary::<acos>();
Self::test_unary::<atan>();
Self::test_unary::<exp>();
Self::test_unary::<ln>();
Self::test_unary::<square>();
Self::test_unary::<sqrt>();
}

pub fn test_binary<C: CanonicalBinaryOp>() {
Self::test_binary_reg_reg::<C>();
Self::test_binary_reg_imm::<C>();
Self::test_binary_imm_reg::<C>();
}

pub fn test_f_binary_ops() {
use super::canonical::*;

Self::test_binary::<add>();
Self::test_binary::<sub>();
Self::test_binary::<mul>();
Self::test_binary::<div>();
Self::test_binary::<min>();
Self::test_binary::<max>();
}
}

#[macro_export]
Expand All @@ -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>
);
}
};
}
45 changes: 14 additions & 31 deletions fidget/src/core/eval/test/grad_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,40 +699,11 @@ where
}
}

pub fn test_g_unary_ops() {
use super::canonical::*;

Self::test_unary::<neg>();
Self::test_unary::<recip>();
Self::test_unary::<abs>();
Self::test_unary::<sin>();
Self::test_unary::<cos>();
Self::test_unary::<tan>();
Self::test_unary::<asin>();
Self::test_unary::<acos>();
Self::test_unary::<atan>();
Self::test_unary::<exp>();
Self::test_unary::<ln>();
Self::test_unary::<square>();
Self::test_unary::<sqrt>();
}

pub fn test_binary<C: CanonicalBinaryOp>() {
Self::test_binary_reg_reg::<C>();
Self::test_binary_reg_imm::<C>();
Self::test_binary_imm_reg::<C>();
}

pub fn test_g_binary_ops() {
use super::canonical::*;

Self::test_binary::<add>();
Self::test_binary::<sub>();
Self::test_binary::<mul>();
Self::test_binary::<div>();
Self::test_binary::<min>();
Self::test_binary::<max>();
}
}

#[macro_export]
Expand Down Expand Up @@ -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>
);
}
};
}
45 changes: 14 additions & 31 deletions fidget/src/core/eval/test/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,40 +889,11 @@ where
}
}

pub fn test_i_unary_ops() {
use super::canonical::*;

Self::test_unary::<neg>();
Self::test_unary::<recip>();
Self::test_unary::<abs>();
Self::test_unary::<sin>();
Self::test_unary::<cos>();
Self::test_unary::<tan>();
Self::test_unary::<asin>();
Self::test_unary::<acos>();
Self::test_unary::<atan>();
Self::test_unary::<exp>();
Self::test_unary::<ln>();
Self::test_unary::<square>();
Self::test_unary::<sqrt>();
}

pub fn test_binary<C: CanonicalBinaryOp>() {
Self::test_binary_reg_reg::<C>();
Self::test_binary_reg_imm::<C>();
Self::test_binary_imm_reg::<C>();
}

pub fn test_i_binary_ops() {
use super::canonical::*;

Self::test_binary::<add>();
Self::test_binary::<sub>();
Self::test_binary::<mul>();
Self::test_binary::<div>();
Self::test_binary::<min>();
Self::test_binary::<max>();
}
}

#[macro_export]
Expand Down Expand Up @@ -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>
);
}
};
}
53 changes: 52 additions & 1 deletion fidget/src/core/eval/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
};
}
45 changes: 14 additions & 31 deletions fidget/src/core/eval/test/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,35 +556,6 @@ where
Self::test_binary_reg_imm::<C>();
Self::test_binary_imm_reg::<C>();
}

pub fn test_p_binary_ops() {
use super::canonical::*;

Self::test_binary::<add>();
Self::test_binary::<sub>();
Self::test_binary::<mul>();
Self::test_binary::<div>();
Self::test_binary::<min>();
Self::test_binary::<max>();
}

pub fn test_p_unary_ops() {
use super::canonical::*;

Self::test_unary::<neg>();
Self::test_unary::<recip>();
Self::test_unary::<abs>();
Self::test_unary::<sin>();
Self::test_unary::<cos>();
Self::test_unary::<tan>();
Self::test_unary::<asin>();
Self::test_unary::<acos>();
Self::test_unary::<atan>();
Self::test_unary::<exp>();
Self::test_unary::<ln>();
Self::test_unary::<square>();
Self::test_unary::<sqrt>();
}
}

#[macro_export]
Expand All @@ -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>
);
}
};
}