diff options
| author | Robin Kruppe <robin.kruppe@gmail.com> | 2016-01-26 22:05:21 +0100 |
|---|---|---|
| committer | Robin Kruppe <robin.kruppe@gmail.com> | 2016-02-04 16:27:22 +0100 |
| commit | a8dc1f974be05b80b2edf17b62eee47e38edf2de (patch) | |
| tree | b12180bec9771837c4868f0285f5b064a7f547bd /src/etc/test-float-parse | |
| parent | 25c9ac32804ff3d513020f02a8bbe5bc1afd6504 (diff) | |
| download | rust-a8dc1f974be05b80b2edf17b62eee47e38edf2de.tar.gz rust-a8dc1f974be05b80b2edf17b62eee47e38edf2de.zip | |
Add the kind of input from #31109 to the expensive tests (not run by default)
Diffstat (limited to 'src/etc/test-float-parse')
| -rw-r--r-- | src/etc/test-float-parse/_common.rs | 2 | ||||
| -rw-r--r-- | src/etc/test-float-parse/few-ones.rs | 2 | ||||
| -rw-r--r-- | src/etc/test-float-parse/huge-pow10.rs | 2 | ||||
| -rw-r--r-- | src/etc/test-float-parse/long-fractions.rs | 27 | ||||
| -rw-r--r-- | src/etc/test-float-parse/many-digits.rs | 4 | ||||
| -rw-r--r-- | src/etc/test-float-parse/rand-f64.rs | 2 | ||||
| -rw-r--r-- | src/etc/test-float-parse/short-decimals.rs | 4 | ||||
| -rw-r--r-- | src/etc/test-float-parse/subnorm.rs | 4 | ||||
| -rw-r--r-- | src/etc/test-float-parse/tiny-pow10.rs | 2 | ||||
| -rw-r--r-- | src/etc/test-float-parse/u32-small.rs | 2 | ||||
| -rw-r--r-- | src/etc/test-float-parse/u64-pow2.rs | 8 |
11 files changed, 43 insertions, 16 deletions
diff --git a/src/etc/test-float-parse/_common.rs b/src/etc/test-float-parse/_common.rs index b4a2a593e01..725a715f7cf 100644 --- a/src/etc/test-float-parse/_common.rs +++ b/src/etc/test-float-parse/_common.rs @@ -16,7 +16,7 @@ use std::mem::transmute; #[allow(dead_code)] pub const SEED: [u32; 3] = [0x243f_6a88, 0x85a3_08d3, 0x1319_8a2e]; -pub fn validate(text: String) { +pub fn validate(text: &str) { let mut out = io::stdout(); let x: f64 = text.parse().unwrap(); let f64_bytes: u64 = unsafe { transmute(x) }; diff --git a/src/etc/test-float-parse/few-ones.rs b/src/etc/test-float-parse/few-ones.rs index 390f4da6f63..2486df44466 100644 --- a/src/etc/test-float-parse/few-ones.rs +++ b/src/etc/test-float-parse/few-ones.rs @@ -20,7 +20,7 @@ fn main() { for a in &pow { for b in &pow { for c in &pow { - validate((a | b | c).to_string()); + validate(&(a | b | c).to_string()); } } } diff --git a/src/etc/test-float-parse/huge-pow10.rs b/src/etc/test-float-parse/huge-pow10.rs index e62afc78515..9d12a03dae2 100644 --- a/src/etc/test-float-parse/huge-pow10.rs +++ b/src/etc/test-float-parse/huge-pow10.rs @@ -15,7 +15,7 @@ use _common::validate; fn main() { for e in 300..310 { for i in 0..100000 { - validate(format!("{}e{}", i, e)); + validate(&format!("{}e{}", i, e)); } } } diff --git a/src/etc/test-float-parse/long-fractions.rs b/src/etc/test-float-parse/long-fractions.rs new file mode 100644 index 00000000000..9598bd12a0d --- /dev/null +++ b/src/etc/test-float-parse/long-fractions.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod _common; + +use std::char; +use _common::validate; + +fn main() { + for n in 0..10 { + let digit = char::from_digit(n, 10).unwrap(); + let mut s = "0.".to_string(); + for _ in 0..400 { + s.push(digit); + if s.parse::<f64>().is_ok() { + validate(&s); + } + } + } +} diff --git a/src/etc/test-float-parse/many-digits.rs b/src/etc/test-float-parse/many-digits.rs index 0cbf57183df..674c30ad84e 100644 --- a/src/etc/test-float-parse/many-digits.rs +++ b/src/etc/test-float-parse/many-digits.rs @@ -23,9 +23,9 @@ fn main() { let mut rnd = IsaacRng::from_seed(&SEED); let mut range = Range::new(0, 10); for _ in 0..5_000_000u64 { - let num_digits = rnd.gen_range(100, 300); + let num_digits = rnd.gen_range(100, 400); let digits = gen_digits(num_digits, &mut range, &mut rnd); - validate(digits); + validate(&digits); } } diff --git a/src/etc/test-float-parse/rand-f64.rs b/src/etc/test-float-parse/rand-f64.rs index 762c3d95ec6..1d82912054e 100644 --- a/src/etc/test-float-parse/rand-f64.rs +++ b/src/etc/test-float-parse/rand-f64.rs @@ -25,7 +25,7 @@ fn main() { let bits = rnd.next_u64(); let x: f64 = unsafe { transmute(bits) }; if x.is_finite() { - validate(format!("{:e}", x)); + validate(&format!("{:e}", x)); i += 1; } } diff --git a/src/etc/test-float-parse/short-decimals.rs b/src/etc/test-float-parse/short-decimals.rs index baefb9c9305..4909f7c58f8 100644 --- a/src/etc/test-float-parse/short-decimals.rs +++ b/src/etc/test-float-parse/short-decimals.rs @@ -22,8 +22,8 @@ fn main() { if i % 10 == 0 { continue; } - validate(format!("{}e{}", i, e)); - validate(format!("{}e-{}", i, e)); + validate(&format!("{}e{}", i, e)); + validate(&format!("{}e-{}", i, e)); } } } diff --git a/src/etc/test-float-parse/subnorm.rs b/src/etc/test-float-parse/subnorm.rs index 70682c9b218..04a7cc27466 100644 --- a/src/etc/test-float-parse/subnorm.rs +++ b/src/etc/test-float-parse/subnorm.rs @@ -16,8 +16,8 @@ use _common::validate; fn main() { for bits in 0u32..(1 << 21) { let single: f32 = unsafe { transmute(bits) }; - validate(format!("{:e}", single)); + validate(&format!("{:e}", single)); let double: f64 = unsafe { transmute(bits as u64) }; - validate(format!("{:e}", double)); + validate(&format!("{:e}", double)); } } diff --git a/src/etc/test-float-parse/tiny-pow10.rs b/src/etc/test-float-parse/tiny-pow10.rs index a01c6d5a078..50ca5e32609 100644 --- a/src/etc/test-float-parse/tiny-pow10.rs +++ b/src/etc/test-float-parse/tiny-pow10.rs @@ -15,7 +15,7 @@ use _common::validate; fn main() { for e in 301..327 { for i in 0..100000 { - validate(format!("{}e-{}", i, e)); + validate(&format!("{}e-{}", i, e)); } } } diff --git a/src/etc/test-float-parse/u32-small.rs b/src/etc/test-float-parse/u32-small.rs index a4e8488e745..571ac80e5b0 100644 --- a/src/etc/test-float-parse/u32-small.rs +++ b/src/etc/test-float-parse/u32-small.rs @@ -14,6 +14,6 @@ use _common::validate; fn main() { for i in 0..(1 << 19) { - validate(i.to_string()); + validate(&i.to_string()); } } diff --git a/src/etc/test-float-parse/u64-pow2.rs b/src/etc/test-float-parse/u64-pow2.rs index a31304d3f68..5b25c839931 100644 --- a/src/etc/test-float-parse/u64-pow2.rs +++ b/src/etc/test-float-parse/u64-pow2.rs @@ -16,13 +16,13 @@ use std::u64; fn main() { for exp in 19..64 { let power: u64 = 1 << exp; - validate(power.to_string()); + validate(&power.to_string()); for offset in 1..123 { - validate((power + offset).to_string()); - validate((power - offset).to_string()); + validate(&(power + offset).to_string()); + validate(&(power - offset).to_string()); } } for offset in 0..123 { - validate((u64::MAX - offset).to_string()); + validate(&(u64::MAX - offset).to_string()); } } |
