std: Fix float tests
This commit is contained in:
parent
c365252002
commit
d12a136b22
4 changed files with 19 additions and 48 deletions
|
@ -43,32 +43,6 @@ mod num;
|
|||
mod float;
|
||||
pub mod rt;
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[allow(missing_doc)]
|
||||
pub mod parse {
|
||||
#[deriving(Eq)]
|
||||
pub enum Alignment {
|
||||
AlignLeft,
|
||||
AlignRight,
|
||||
AlignUnknown,
|
||||
}
|
||||
|
||||
pub enum PluralKeyword {
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
Few,
|
||||
Many,
|
||||
}
|
||||
|
||||
pub enum Flag {
|
||||
FlagSignPlus,
|
||||
FlagSignMinus,
|
||||
FlagAlternate,
|
||||
FlagSignAwareZeroPad,
|
||||
}
|
||||
}
|
||||
|
||||
pub type Result = result::Result<(), FormatError>;
|
||||
|
||||
/// dox
|
||||
|
@ -98,7 +72,7 @@ pub struct Formatter<'a> {
|
|||
/// Optionally specified precision for numeric types
|
||||
pub precision: Option<uint>,
|
||||
|
||||
/// dox
|
||||
#[allow(missing_doc)]
|
||||
#[cfg(stage0)]
|
||||
pub buf: &'a mut FormatWriter,
|
||||
#[cfg(not(stage0))]
|
||||
|
|
|
@ -492,9 +492,6 @@ use str::{StrAllocating};
|
|||
use str;
|
||||
use slice::Vector;
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub use core::fmt::parse;
|
||||
|
||||
pub use core::fmt::{Formatter, Result, FormatWriter, Show, rt};
|
||||
pub use core::fmt::{Show, Bool, Char, Signed, Unsigned, Octal, Binary};
|
||||
pub use core::fmt::{LowerHex, UpperHex, String, Pointer};
|
||||
|
|
|
@ -734,18 +734,18 @@ mod tests {
|
|||
// are supported in floating-point literals
|
||||
let f1: f32 = from_str_hex("1p-123").unwrap();
|
||||
let f2: f32 = from_str_hex("1p-111").unwrap();
|
||||
assert_eq!(Float::ldexp(1f32, -123), f1);
|
||||
assert_eq!(Float::ldexp(1f32, -111), f2);
|
||||
assert_eq!(FloatMath::ldexp(1f32, -123), f1);
|
||||
assert_eq!(FloatMath::ldexp(1f32, -111), f2);
|
||||
|
||||
assert_eq!(Float::ldexp(0f32, -123), 0f32);
|
||||
assert_eq!(Float::ldexp(-0f32, -123), -0f32);
|
||||
assert_eq!(FloatMath::ldexp(0f32, -123), 0f32);
|
||||
assert_eq!(FloatMath::ldexp(-0f32, -123), -0f32);
|
||||
|
||||
let inf: f32 = Float::infinity();
|
||||
let neg_inf: f32 = Float::neg_infinity();
|
||||
let nan: f32 = Float::nan();
|
||||
assert_eq!(Float::ldexp(inf, -123), inf);
|
||||
assert_eq!(Float::ldexp(neg_inf, -123), neg_inf);
|
||||
assert!(Float::ldexp(nan, -123).is_nan());
|
||||
assert_eq!(FloatMath::ldexp(inf, -123), inf);
|
||||
assert_eq!(FloatMath::ldexp(neg_inf, -123), neg_inf);
|
||||
assert!(FloatMath::ldexp(nan, -123).is_nan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -758,8 +758,8 @@ mod tests {
|
|||
let (x2, exp2) = f2.frexp();
|
||||
assert_eq!((x1, exp1), (0.5f32, -122));
|
||||
assert_eq!((x2, exp2), (0.5f32, -110));
|
||||
assert_eq!(Float::ldexp(x1, exp1), f1);
|
||||
assert_eq!(Float::ldexp(x2, exp2), f2);
|
||||
assert_eq!(FloatMath::ldexp(x1, exp1), f1);
|
||||
assert_eq!(FloatMath::ldexp(x2, exp2), f2);
|
||||
|
||||
assert_eq!(0f32.frexp(), (0f32, 0));
|
||||
assert_eq!((-0f32).frexp(), (-0f32, 0));
|
||||
|
|
|
@ -734,18 +734,18 @@ mod tests {
|
|||
// are supported in floating-point literals
|
||||
let f1: f64 = from_str_hex("1p-123").unwrap();
|
||||
let f2: f64 = from_str_hex("1p-111").unwrap();
|
||||
assert_eq!(Float::ldexp(1f64, -123), f1);
|
||||
assert_eq!(Float::ldexp(1f64, -111), f2);
|
||||
assert_eq!(FloatMath::ldexp(1f64, -123), f1);
|
||||
assert_eq!(FloatMath::ldexp(1f64, -111), f2);
|
||||
|
||||
assert_eq!(Float::ldexp(0f64, -123), 0f64);
|
||||
assert_eq!(Float::ldexp(-0f64, -123), -0f64);
|
||||
assert_eq!(FloatMath::ldexp(0f64, -123), 0f64);
|
||||
assert_eq!(FloatMath::ldexp(-0f64, -123), -0f64);
|
||||
|
||||
let inf: f64 = Float::infinity();
|
||||
let neg_inf: f64 = Float::neg_infinity();
|
||||
let nan: f64 = Float::nan();
|
||||
assert_eq!(Float::ldexp(inf, -123), inf);
|
||||
assert_eq!(Float::ldexp(neg_inf, -123), neg_inf);
|
||||
assert!(Float::ldexp(nan, -123).is_nan());
|
||||
assert_eq!(FloatMath::ldexp(inf, -123), inf);
|
||||
assert_eq!(FloatMath::ldexp(neg_inf, -123), neg_inf);
|
||||
assert!(FloatMath::ldexp(nan, -123).is_nan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -758,8 +758,8 @@ mod tests {
|
|||
let (x2, exp2) = f2.frexp();
|
||||
assert_eq!((x1, exp1), (0.5f64, -122));
|
||||
assert_eq!((x2, exp2), (0.5f64, -110));
|
||||
assert_eq!(Float::ldexp(x1, exp1), f1);
|
||||
assert_eq!(Float::ldexp(x2, exp2), f2);
|
||||
assert_eq!(FloatMath::ldexp(x1, exp1), f1);
|
||||
assert_eq!(FloatMath::ldexp(x2, exp2), f2);
|
||||
|
||||
assert_eq!(0f64.frexp(), (0f64, 0));
|
||||
assert_eq!((-0f64).frexp(), (-0f64, 0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue