mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
Add the kind of input from #31109 to the expensive tests (not run by default)
This commit is contained in:
parent
25c9ac3280
commit
a8dc1f974b
@ -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) };
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
src/etc/test-float-parse/long-fractions.rs
Normal file
27
src/etc/test-float-parse/long-fractions.rs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ use _common::validate;
|
||||
|
||||
fn main() {
|
||||
for i in 0..(1 << 19) {
|
||||
validate(i.to_string());
|
||||
validate(&i.to_string());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user