Skip to content

Commit

Permalink
test sort_unstable in Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 17, 2019
1 parent 9b21324 commit d55e4b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/liballoc/tests/slice.rs
Expand Up @@ -468,16 +468,16 @@ fn test_sort() {
#[test]
fn test_sort_stability() {
#[cfg(not(miri))] // Miri is too slow
let large_limit = 510;
let large_range = 500..510;
#[cfg(not(miri))] // Miri is too slow
let rounds = 10;

#[cfg(miri)]
let large_limit = 500; // effectively skips the large tests
let large_range = 0..0; // empty range
#[cfg(miri)]
let rounds = 1;

for len in (2..25).chain(500..large_limit) {
for len in (2..25).chain(large_range) {
for _ in 0..rounds {
let mut counts = [0; 10];

Expand Down
15 changes: 12 additions & 3 deletions src/libcore/tests/slice.rs
Expand Up @@ -1024,22 +1024,31 @@ fn test_rotate_right() {

#[test]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(miri))] // Miri is too slow
fn sort_unstable() {
use core::cmp::Ordering::{Equal, Greater, Less};
use core::slice::heapsort;
use rand::{FromEntropy, Rng, rngs::SmallRng, seq::SliceRandom};

#[cfg(not(miri))] // Miri is too slow
let large_range = 500..510;
#[cfg(not(miri))] // Miri is too slow
let rounds = 100;

#[cfg(miri)]
let large_range = 0..0; // empty range
#[cfg(miri)]
let rounds = 1;

let mut v = [0; 600];
let mut tmp = [0; 600];
let mut rng = SmallRng::from_entropy();

for len in (2..25).chain(500..510) {
for len in (2..25).chain(large_range) {
let v = &mut v[0..len];
let tmp = &mut tmp[0..len];

for &modulus in &[5, 10, 100, 1000] {
for _ in 0..100 {
for _ in 0..rounds {
for i in 0..len {
v[i] = rng.gen::<i32>() % modulus;
}
Expand Down

0 comments on commit d55e4b7

Please sign in to comment.