Capitalize statics in f32 and f64 mods

Fixes #10077
This commit is contained in:
Ziad Hatahet 2013-10-28 17:34:33 -07:00
parent cd6e9f4f83
commit 3797f2bfe6
8 changed files with 169 additions and 175 deletions

View file

@ -16,7 +16,7 @@ fn lerp(a: f32, b: f32, v: f32) -> f32 { a * (1.0 - v) + b * v }
fn smooth(v: f32) -> f32 { v * v * (3.0 - 2.0 * v) }
fn random_gradient<R:Rng>(r: &mut R) -> Vec2 {
let v = 2.0 * f64::consts::pi * r.gen();
let v = 2.0 * f64::consts::PI * r.gen();
Vec2 {
x: v.cos() as f32,
y: v.sin() as f32,

View file

@ -1,18 +1,16 @@
#[allow(non_uppercase_pattern_statics)];
// Matching against NaN should result in a warning
use std::f64::NaN;
use std::f64::NAN;
fn main() {
let x = NaN;
let x = NAN;
match x {
NaN => {},
NAN => {},
_ => {},
};
//~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead
match [x, 1.0] {
[NaN, _] => {},
[NAN, _] => {},
_ => {},
};
//~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead

View file

@ -61,31 +61,31 @@ pub fn main() {
assert!((powif64(23.2f64, 2i32).approx_eq(&538.24f64)));
assert!((sinf32(0f32).approx_eq(&0f32)));
assert!((sinf64(f64::consts::pi / 2f64).approx_eq(&1f64)));
assert!((sinf64(f64::consts::PI / 2f64).approx_eq(&1f64)));
assert!((cosf32(0f32).approx_eq(&1f32)));
assert!((cosf64(f64::consts::pi * 2f64).approx_eq(&1f64)));
assert!((cosf64(f64::consts::PI * 2f64).approx_eq(&1f64)));
assert!((powf32(25f32, -2f32).approx_eq(&0.0016f32)));
assert!((powf64(400f64, 0.5f64).approx_eq(&20f64)));
assert!((fabsf32(expf32(1f32) - f32::consts::e).approx_eq(&0f32)));
assert!((expf64(1f64).approx_eq(&f64::consts::e)));
assert!((fabsf32(expf32(1f32) - f32::consts::E).approx_eq(&0f32)));
assert!((expf64(1f64).approx_eq(&f64::consts::E)));
assert!((exp2f32(10f32).approx_eq(&1024f32)));
assert!((exp2f64(50f64).approx_eq(&1125899906842624f64)));
assert!((fabsf32(logf32(f32::consts::e) - 1f32).approx_eq(&0f32)));
assert!((fabsf32(logf32(f32::consts::E) - 1f32).approx_eq(&0f32)));
assert!((logf64(1f64).approx_eq(&0f64)));
assert!((log10f32(10f32).approx_eq(&1f32)));
assert!((log10f64(f64::consts::e).approx_eq(&f64::consts::log10_e)));
assert!((log10f64(f64::consts::E).approx_eq(&f64::consts::LOG10_E)));
assert!((log2f32(8f32).approx_eq(&3f32)));
assert!((log2f64(f64::consts::e).approx_eq(&f64::consts::log2_e)));
assert!((log2f64(f64::consts::E).approx_eq(&f64::consts::LOG2_E)));
assert!((fmaf32(1.0f32, 2.0f32, 5.0f32).approx_eq(&7.0f32)));
assert!((fmaf64(0.0f64, -2.0f64, f64::consts::e).approx_eq(&f64::consts::e)));
assert!((fmaf64(0.0f64, -2.0f64, f64::consts::E).approx_eq(&f64::consts::E)));
assert!((fabsf32(-1.0f32).approx_eq(&1.0f32)));
assert!((fabsf64(34.2f64).approx_eq(&34.2f64)));

View file

@ -27,7 +27,7 @@ pub enum Shape {
impl Shape {
pub fn area(&self, sh: Shape) -> f64 {
match sh {
Circle(_, size) => f64::consts::pi * size * size,
Circle(_, size) => f64::consts::PI * size * size,
Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y)
}
}