Skip to content
Permalink
Browse files

test sort_unstable in Miri

  • Loading branch information...
RalfJung committed Apr 17, 2019
1 parent 9b21324 commit d55e4b7a259b887202be91708f839a75b234697c
Showing with 15 additions and 6 deletions.
  1. +3 −3 src/liballoc/tests/slice.rs
  2. +12 −3 src/libcore/tests/slice.rs
@@ -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];

@@ -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;
}

0 comments on commit d55e4b7

Please sign in to comment.
You can’t perform that action at this time.