libcore: more compact way to adjust test sizes for Miri

This commit is contained in:
Ralf Jung 2020-04-23 19:48:35 +02:00
parent 66f7a5d92f
commit f1c30519f3
3 changed files with 16 additions and 30 deletions

View File

@ -52,12 +52,10 @@ fn test_estimate_scaling_factor() {
assert_almost_eq!(estimate_scaling_factor(1, -1074), -323);
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);
#[cfg(not(miri))] // Miri is too slow
let iter = -1074..972;
#[cfg(miri)]
let iter = (-1074..972).step_by(37);
// Miri is too slow
let step = if cfg!(miri) { 37 } else { 1 };
for i in iter {
for i in (-1074..972).step_by(step) {
let expected = super::ldexp_f64(1.0, i).log10().ceil();
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
}

View File

@ -138,13 +138,11 @@ where
#[test]
fn shortest_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_shortest as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 10_000;
#[cfg(miri)]
const N: usize = 10;
// Miri is too slow
let n = if cfg!(miri) { 10 } else { 10_000 };
f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, n);
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, n);
}
#[test]
@ -173,17 +171,15 @@ fn shortest_f64_hard_random_equivalence_test() {
#[test]
fn exact_f32_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 1_000;
#[cfg(miri)]
const N: usize = 3;
// Miri is too slow
let n = if cfg!(miri) { 3 } else { 1_000 };
for k in 1..21 {
f32_random_equivalence_test(
|d, buf| format_exact_opt(d, buf, i16::MIN),
|d, buf| fallback(d, buf, i16::MIN),
k,
N,
n,
);
}
}
@ -191,17 +187,15 @@ fn exact_f32_random_equivalence_test() {
#[test]
fn exact_f64_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 1_000;
#[cfg(miri)]
const N: usize = 3;
// Miri is too slow
let n = if cfg!(miri) { 3 } else { 1_000 };
for k in 1..21 {
f64_random_equivalence_test(
|d, buf| format_exact_opt(d, buf, i16::MIN),
|d, buf| fallback(d, buf, i16::MIN),
k,
N,
n,
);
}
}

View File

@ -1227,15 +1227,9 @@ fn sort_unstable() {
use core::slice::heapsort;
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
#[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;
// Miri is too slow
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
let rounds = if cfg!(miri) { 1 } else { 100 };
let mut v = [0; 600];
let mut tmp = [0; 600];