diff --git a/src/tests/system.rs b/src/tests/system.rs index 8c8fd570..afbbc40b 100644 --- a/src/tests/system.rs +++ b/src/tests/system.rs @@ -375,10 +375,16 @@ mod float { } #[allow(trivial_casts)] - fn clamp(x: A, min: A, max: A) -> bool { - Test::eq( - &Length::new::(x.clamp(*min, *max)), - &Length::new::(*x).clamp(Length::new::(*min), Length::new::(*max))) + fn clamp(x: A, min: A, max: A) -> TestResult { + if *min > *max || min.is_nan() || max.is_nan() { + return TestResult::discard(); + } + TestResult::from_bool( + Test::eq( + &Length::new::(x.clamp(*min, *max)), + &Length::new::(*x).clamp(Length::new::(*min), Length::new::(*max)) + ) + ) } } } @@ -582,13 +588,19 @@ mod fixed { } #[allow(trivial_casts)] - fn clamp(x: A, min: A, max: A) -> bool { - Test::eq(&Length::new::((*x).clone().clamp((*min).clone(), (*max).clone())), - &Ord::clamp( - Length::new::((*x).clone()), - Length::new::((*min).clone()), - Length::new::((*max).clone()), - )) + fn clamp(x: A, min: A, max: A) -> TestResult { + if *min > *max { + return TestResult::discard() + } + TestResult::from_bool( + Test::eq(&Length::new::((*x).clone().clamp((*min).clone(), (*max).clone())), + &Ord::clamp( + Length::new::((*x).clone()), + Length::new::((*min).clone()), + Length::new::((*max).clone()), + ) + ) + ) } } }