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.
This commit is contained in:
parent
7613b15fdb
commit
ceea85a148
18 changed files with 164 additions and 299 deletions
|
@ -741,43 +741,6 @@ pub fn std_macros() -> @str {
|
|||
)
|
||||
)
|
||||
|
||||
macro_rules! assert_approx_eq (
|
||||
($given:expr , $expected:expr) => (
|
||||
{
|
||||
use std::cmp::ApproxEq;
|
||||
|
||||
let given_val = $given;
|
||||
let expected_val = $expected;
|
||||
// check both directions of equality....
|
||||
if !(
|
||||
given_val.approx_eq(&expected_val) &&
|
||||
expected_val.approx_eq(&given_val)
|
||||
) {
|
||||
fail!("left: {:?} does not approximately equal right: {:?}",
|
||||
given_val, expected_val);
|
||||
}
|
||||
}
|
||||
);
|
||||
($given:expr , $expected:expr , $epsilon:expr) => (
|
||||
{
|
||||
use std::cmp::ApproxEq;
|
||||
|
||||
let given_val = $given;
|
||||
let expected_val = $expected;
|
||||
let epsilon_val = $epsilon;
|
||||
// check both directions of equality....
|
||||
if !(
|
||||
given_val.approx_eq_eps(&expected_val, &epsilon_val) &&
|
||||
expected_val.approx_eq_eps(&given_val, &epsilon_val)
|
||||
) {
|
||||
fail!("left: {:?} does not approximately equal right: \
|
||||
{:?} with epsilon: {:?}",
|
||||
given_val, expected_val, epsilon_val);
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
/// A utility macro for indicating unreachable code. It will fail if
|
||||
/// executed. This is occasionally useful to put after loops that never
|
||||
/// terminate normally, but instead directly return from a function.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue