Skip to content

Commit

Permalink
Add the kind of input from #31109 to the expensive tests (not run by …
Browse files Browse the repository at this point in the history
…default)
  • Loading branch information
Robin Kruppe committed Feb 4, 2016
1 parent 25c9ac3 commit a8dc1f9
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/etc/test-float-parse/_common.rs
Expand Up @@ -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) };
Expand Down
2 changes: 1 addition & 1 deletion src/etc/test-float-parse/few-ones.rs
Expand Up @@ -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());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/etc/test-float-parse/huge-pow10.rs
Expand Up @@ -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));
}
}
}
27 changes: 27 additions & 0 deletions 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);
}
}
}
}
4 changes: 2 additions & 2 deletions src/etc/test-float-parse/many-digits.rs
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/etc/test-float-parse/rand-f64.rs
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/etc/test-float-parse/short-decimals.rs
Expand Up @@ -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));
}
}
}
4 changes: 2 additions & 2 deletions src/etc/test-float-parse/subnorm.rs
Expand Up @@ -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));
}
}
2 changes: 1 addition & 1 deletion src/etc/test-float-parse/tiny-pow10.rs
Expand Up @@ -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));
}
}
}
2 changes: 1 addition & 1 deletion src/etc/test-float-parse/u32-small.rs
Expand Up @@ -14,6 +14,6 @@ use _common::validate;

fn main() {
for i in 0..(1 << 19) {
validate(i.to_string());
validate(&i.to_string());
}
}
8 changes: 4 additions & 4 deletions src/etc/test-float-parse/u64-pow2.rs
Expand Up @@ -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());
}
}

0 comments on commit a8dc1f9

Please sign in to comment.