1
Fork 0

test sort_unstable in Miri

This commit is contained in:
Ralf Jung 2019-04-17 09:47:36 +02:00
parent 9b21324db2
commit d55e4b7a25
2 changed files with 15 additions and 6 deletions

View file

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

View file

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