mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
bump libcore tests to rand 0.7
This commit is contained in:
parent
5b78e98a37
commit
0cb16f7d5e
@ -514,7 +514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
name = "core"
|
name = "core"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -21,7 +21,7 @@ name = "corebenches"
|
|||||||
path = "../libcore/benches/lib.rs"
|
path = "../libcore/benches/lib.rs"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.6"
|
rand = "0.7"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Make panics and failed asserts immediately abort without formatting any message
|
# Make panics and failed asserts immediately abort without formatting any message
|
||||||
|
@ -8,8 +8,8 @@ use core::num::flt2dec::strategy::grisu::format_exact_opt;
|
|||||||
use core::num::flt2dec::strategy::grisu::format_shortest_opt;
|
use core::num::flt2dec::strategy::grisu::format_shortest_opt;
|
||||||
use core::num::flt2dec::{decode, DecodableFloat, FullDecoded, Decoded};
|
use core::num::flt2dec::{decode, DecodableFloat, FullDecoded, Decoded};
|
||||||
|
|
||||||
use rand::FromEntropy;
|
use rand::SeedableRng;
|
||||||
use rand::rngs::SmallRng;
|
use rand::rngs::StdRng;
|
||||||
use rand::distributions::{Distribution, Uniform};
|
use rand::distributions::{Distribution, Uniform};
|
||||||
|
|
||||||
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
|
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
|
||||||
@ -65,7 +65,7 @@ pub fn f32_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
|
|||||||
if cfg!(target_os = "emscripten") {
|
if cfg!(target_os = "emscripten") {
|
||||||
return // using rng pulls in i128 support, which doesn't work
|
return // using rng pulls in i128 support, which doesn't work
|
||||||
}
|
}
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = StdRng::from_entropy();
|
||||||
let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000);
|
let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000);
|
||||||
iterate("f32_random_equivalence_test", k, n, f, g, |_| {
|
iterate("f32_random_equivalence_test", k, n, f, g, |_| {
|
||||||
let x = f32::from_bits(f32_range.sample(&mut rng));
|
let x = f32::from_bits(f32_range.sample(&mut rng));
|
||||||
@ -79,7 +79,7 @@ pub fn f64_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
|
|||||||
if cfg!(target_os = "emscripten") {
|
if cfg!(target_os = "emscripten") {
|
||||||
return // using rng pulls in i128 support, which doesn't work
|
return // using rng pulls in i128 support, which doesn't work
|
||||||
}
|
}
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = StdRng::from_entropy();
|
||||||
let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000);
|
let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000);
|
||||||
iterate("f64_random_equivalence_test", k, n, f, g, |_| {
|
iterate("f64_random_equivalence_test", k, n, f, g, |_| {
|
||||||
let x = f64::from_bits(f64_range.sample(&mut rng));
|
let x = f64::from_bits(f64_range.sample(&mut rng));
|
||||||
|
@ -1157,7 +1157,7 @@ fn test_rotate_right() {
|
|||||||
fn sort_unstable() {
|
fn sort_unstable() {
|
||||||
use core::cmp::Ordering::{Equal, Greater, Less};
|
use core::cmp::Ordering::{Equal, Greater, Less};
|
||||||
use core::slice::heapsort;
|
use core::slice::heapsort;
|
||||||
use rand::{FromEntropy, Rng, rngs::SmallRng, seq::SliceRandom};
|
use rand::{SeedableRng, Rng, rngs::StdRng, seq::SliceRandom};
|
||||||
|
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
#[cfg(not(miri))] // Miri is too slow
|
||||||
let large_range = 500..510;
|
let large_range = 500..510;
|
||||||
@ -1171,7 +1171,7 @@ fn sort_unstable() {
|
|||||||
|
|
||||||
let mut v = [0; 600];
|
let mut v = [0; 600];
|
||||||
let mut tmp = [0; 600];
|
let mut tmp = [0; 600];
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = StdRng::from_entropy();
|
||||||
|
|
||||||
for len in (2..25).chain(large_range) {
|
for len in (2..25).chain(large_range) {
|
||||||
let v = &mut v[0..len];
|
let v = &mut v[0..len];
|
||||||
@ -1237,11 +1237,11 @@ fn sort_unstable() {
|
|||||||
#[cfg(not(miri))] // Miri is too slow
|
#[cfg(not(miri))] // Miri is too slow
|
||||||
fn partition_at_index() {
|
fn partition_at_index() {
|
||||||
use core::cmp::Ordering::{Equal, Greater, Less};
|
use core::cmp::Ordering::{Equal, Greater, Less};
|
||||||
use rand::rngs::SmallRng;
|
use rand::rngs::StdRng;
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use rand::{FromEntropy, Rng};
|
use rand::{SeedableRng, Rng};
|
||||||
|
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = StdRng::from_entropy();
|
||||||
|
|
||||||
for len in (2..21).chain(500..501) {
|
for len in (2..21).chain(500..501) {
|
||||||
let mut orig = vec![0; len];
|
let mut orig = vec![0; len];
|
||||||
|
Loading…
Reference in New Issue
Block a user