mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
libcore: more compact way to adjust test sizes for Miri
This commit is contained in:
parent
66f7a5d92f
commit
f1c30519f3
@ -52,12 +52,10 @@ fn test_estimate_scaling_factor() {
|
|||||||
assert_almost_eq!(estimate_scaling_factor(1, -1074), -323);
|
assert_almost_eq!(estimate_scaling_factor(1, -1074), -323);
|
||||||
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);
|
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);
|
||||||
|
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let iter = -1074..972;
|
let step = if cfg!(miri) { 37 } else { 1 };
|
||||||
#[cfg(miri)]
|
|
||||||
let iter = (-1074..972).step_by(37);
|
|
||||||
|
|
||||||
for i in iter {
|
for i in (-1074..972).step_by(step) {
|
||||||
let expected = super::ldexp_f64(1.0, i).log10().ceil();
|
let expected = super::ldexp_f64(1.0, i).log10().ceil();
|
||||||
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
|
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
|
||||||
}
|
}
|
||||||
|
@ -138,13 +138,11 @@ where
|
|||||||
#[test]
|
#[test]
|
||||||
fn shortest_random_equivalence_test() {
|
fn shortest_random_equivalence_test() {
|
||||||
use core::num::flt2dec::strategy::dragon::format_shortest as fallback;
|
use core::num::flt2dec::strategy::dragon::format_shortest as fallback;
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
const N: usize = 10_000;
|
let n = if cfg!(miri) { 10 } else { 10_000 };
|
||||||
#[cfg(miri)]
|
|
||||||
const N: usize = 10;
|
|
||||||
|
|
||||||
f64_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);
|
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -173,17 +171,15 @@ fn shortest_f64_hard_random_equivalence_test() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn exact_f32_random_equivalence_test() {
|
fn exact_f32_random_equivalence_test() {
|
||||||
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
|
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
const N: usize = 1_000;
|
let n = if cfg!(miri) { 3 } else { 1_000 };
|
||||||
#[cfg(miri)]
|
|
||||||
const N: usize = 3;
|
|
||||||
|
|
||||||
for k in 1..21 {
|
for k in 1..21 {
|
||||||
f32_random_equivalence_test(
|
f32_random_equivalence_test(
|
||||||
|d, buf| format_exact_opt(d, buf, i16::MIN),
|
|d, buf| format_exact_opt(d, buf, i16::MIN),
|
||||||
|d, buf| fallback(d, buf, i16::MIN),
|
|d, buf| fallback(d, buf, i16::MIN),
|
||||||
k,
|
k,
|
||||||
N,
|
n,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,17 +187,15 @@ fn exact_f32_random_equivalence_test() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn exact_f64_random_equivalence_test() {
|
fn exact_f64_random_equivalence_test() {
|
||||||
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
|
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
const N: usize = 1_000;
|
let n = if cfg!(miri) { 3 } else { 1_000 };
|
||||||
#[cfg(miri)]
|
|
||||||
const N: usize = 3;
|
|
||||||
|
|
||||||
for k in 1..21 {
|
for k in 1..21 {
|
||||||
f64_random_equivalence_test(
|
f64_random_equivalence_test(
|
||||||
|d, buf| format_exact_opt(d, buf, i16::MIN),
|
|d, buf| format_exact_opt(d, buf, i16::MIN),
|
||||||
|d, buf| fallback(d, buf, i16::MIN),
|
|d, buf| fallback(d, buf, i16::MIN),
|
||||||
k,
|
k,
|
||||||
N,
|
n,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1227,15 +1227,9 @@ fn sort_unstable() {
|
|||||||
use core::slice::heapsort;
|
use core::slice::heapsort;
|
||||||
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
|
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
|
||||||
|
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let large_range = 500..510;
|
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
let rounds = if cfg!(miri) { 1 } else { 100 };
|
||||||
let rounds = 100;
|
|
||||||
|
|
||||||
#[cfg(miri)]
|
|
||||||
let large_range = 0..0; // empty range
|
|
||||||
#[cfg(miri)]
|
|
||||||
let rounds = 1;
|
|
||||||
|
|
||||||
let mut v = [0; 600];
|
let mut v = [0; 600];
|
||||||
let mut tmp = [0; 600];
|
let mut tmp = [0; 600];
|
||||||
|
Loading…
Reference in New Issue
Block a user