From ceea85a148ec3426edfc00b8353a19c1d2df5dbf Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 8 Jan 2014 22:57:31 +1100 Subject: Remove ApproxEq and assert_approx_eq! This trait seems to stray too far from the mandate of a standard library as implementations may vary between use cases. --- src/libextra/num/complex.rs | 2 +- src/libextra/stats.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/libextra') diff --git a/src/libextra/num/complex.rs b/src/libextra/num/complex.rs index 58af80fefb7..b4795c7e66b 100644 --- a/src/libextra/num/complex.rs +++ b/src/libextra/num/complex.rs @@ -268,7 +268,7 @@ mod test { #[test] fn test_arg() { fn test(c: Complex64, arg: f64) { - assert!(c.arg().approx_eq(&arg)) + assert!((c.arg() - arg).abs() < 1.0e-6) } test(_1_0i, 0.0); test(_1_1i, 0.25 * Real::pi()); diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs index f95c12904ff..7b2dcc53b79 100644 --- a/src/libextra/stats.rs +++ b/src/libextra/stats.rs @@ -439,6 +439,14 @@ mod tests { use std::io; use std::str; + macro_rules! assert_approx_eq( + ($a:expr, $b:expr) => ({ + let (a, b) = (&$a, &$b); + assert!((*a - *b).abs() < 1.0e-6, + "{} is not approximately equal to {}", *a, *b); + }) + ) + fn check(samples: &[f64], summ: &Summary) { let summ2 = Summary::new(samples); -- cgit 1.4.1-3-g733a5