Rollup merge of #58433 - RalfJung:miri-mark-tests, r=TimNN

Update which libcore/liballoc tests Miri ignores, and document why
This commit is contained in:
kennytm
2019-02-16 00:55:55 +08:00
24 changed files with 150 additions and 79 deletions

View File

@@ -1,5 +1,3 @@
#![cfg(not(miri))]
use std::any::Any;
use std::sync::{Arc, Weak};
use std::cell::RefCell;

View File

@@ -282,7 +282,7 @@ fn assert_covariance() {
//
// Destructors must be called exactly once per element.
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn panic_safe() {
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);

View File

@@ -9,7 +9,10 @@ use super::DeterministicRng;
#[test]
fn test_basic_large() {
let mut map = BTreeMap::new();
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
assert_eq!(map.len(), 0);
for i in 0..size {
@@ -69,7 +72,10 @@ fn test_basic_small() {
#[test]
fn test_iter() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Forwards
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -91,7 +97,10 @@ fn test_iter() {
#[test]
fn test_iter_rev() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Forwards
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -127,7 +136,10 @@ fn test_values_mut() {
#[test]
fn test_iter_mixed() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Forwards
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -214,6 +226,7 @@ fn test_range_equal_empty_cases() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_equal_excluded() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(2), Excluded(2)));
@@ -221,6 +234,7 @@ fn test_range_equal_excluded() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_1() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Included(3), Included(2)));
@@ -228,6 +242,7 @@ fn test_range_backwards_1() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_2() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Included(3), Excluded(2)));
@@ -235,6 +250,7 @@ fn test_range_backwards_2() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_3() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(3), Included(2)));
@@ -242,6 +258,7 @@ fn test_range_backwards_3() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_range_backwards_4() {
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
map.range((Excluded(3), Excluded(2)));
@@ -249,7 +266,10 @@ fn test_range_backwards_4() {
#[test]
fn test_range_1000() {
#[cfg(not(miri))] // Miri is too slow
let size = 1000;
#[cfg(miri)]
let size = 200;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
@@ -286,7 +306,10 @@ fn test_range_borrowed_key() {
#[test]
fn test_range() {
#[cfg(not(miri))] // Miri is too slow
let size = 200;
#[cfg(miri)]
let size = 30;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
for i in 0..size {
@@ -305,7 +328,10 @@ fn test_range() {
#[test]
fn test_range_mut() {
#[cfg(not(miri))] // Miri is too slow
let size = 200;
#[cfg(miri)]
let size = 30;
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
for i in 0..size {
@@ -479,7 +505,10 @@ fn test_bad_zst() {
#[test]
fn test_clone() {
let mut map = BTreeMap::new();
#[cfg(not(miri))] // Miri is too slow
let size = 100;
#[cfg(miri)]
let size = 30;
assert_eq!(map.len(), 0);
for i in 0..size {
@@ -631,6 +660,7 @@ create_append_test!(test_append_145, 145);
create_append_test!(test_append_170, 170);
create_append_test!(test_append_181, 181);
create_append_test!(test_append_239, 239);
#[cfg(not(miri))] // Miri is too slow
create_append_test!(test_append_1700, 1700);
fn rand_data(len: usize) -> Vec<(u32, u32)> {

View File

@@ -1,5 +1,3 @@
#![cfg(not(miri))]
mod map;
mod set;

View File

@@ -1,5 +1,3 @@
#![cfg(not(miri))]
use std::alloc::{Global, Alloc, Layout, System};
/// Issue #45955.

View File

@@ -1,5 +1,3 @@
#![cfg(not(miri))]
use std::any::Any;
use std::rc::{Rc, Weak};
use std::cell::RefCell;

View File

@@ -1,5 +1,3 @@
#![cfg(not(miri))]
use std::cell::Cell;
use std::cmp::Ordering::{self, Equal, Greater, Less};
use std::mem;
@@ -260,6 +258,7 @@ fn test_swap_remove() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_swap_remove_fail() {
let mut v = vec![1];
let _ = v.swap_remove(0);
@@ -391,6 +390,7 @@ fn test_reverse() {
}
#[test]
#[cfg(not(miri))] // Miri does not support entropy
fn test_sort() {
let mut rng = thread_rng();
@@ -467,6 +467,7 @@ fn test_sort() {
}
#[test]
#[cfg(not(miri))] // Miri does not support entropy
fn test_sort_stability() {
for len in (2..25).chain(500..510) {
for _ in 0..10 {
@@ -631,6 +632,7 @@ fn test_insert() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_insert_oob() {
let mut a = vec![1, 2, 3];
a.insert(4, 5);
@@ -655,6 +657,7 @@ fn test_remove() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_remove_fail() {
let mut a = vec![1];
let _ = a.remove(0);
@@ -936,6 +939,7 @@ fn test_windowsator() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_windowsator_0() {
let v = &[1, 2, 3, 4];
let _it = v.windows(0);
@@ -960,6 +964,7 @@ fn test_chunksator() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_chunksator_0() {
let v = &[1, 2, 3, 4];
let _it = v.chunks(0);
@@ -984,6 +989,7 @@ fn test_chunks_exactator() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_chunks_exactator_0() {
let v = &[1, 2, 3, 4];
let _it = v.chunks_exact(0);
@@ -1008,6 +1014,7 @@ fn test_rchunksator() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_rchunksator_0() {
let v = &[1, 2, 3, 4];
let _it = v.rchunks(0);
@@ -1032,6 +1039,7 @@ fn test_rchunks_exactator() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_rchunks_exactator_0() {
let v = &[1, 2, 3, 4];
let _it = v.rchunks_exact(0);
@@ -1084,6 +1092,7 @@ fn test_vec_default() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_overflow_does_not_cause_segfault() {
let mut v = vec![];
v.reserve_exact(!0);
@@ -1093,6 +1102,7 @@ fn test_overflow_does_not_cause_segfault() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_overflow_does_not_cause_segfault_managed() {
let mut v = vec![Rc::new(1)];
v.reserve_exact(!0);
@@ -1268,6 +1278,7 @@ fn test_mut_chunks_rev() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_mut_chunks_0() {
let mut v = [1, 2, 3, 4];
let _it = v.chunks_mut(0);
@@ -1300,6 +1311,7 @@ fn test_mut_chunks_exact_rev() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_mut_chunks_exact_0() {
let mut v = [1, 2, 3, 4];
let _it = v.chunks_exact_mut(0);
@@ -1332,6 +1344,7 @@ fn test_mut_rchunks_rev() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_mut_rchunks_0() {
let mut v = [1, 2, 3, 4];
let _it = v.rchunks_mut(0);
@@ -1364,6 +1377,7 @@ fn test_mut_rchunks_exact_rev() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_mut_rchunks_exact_0() {
let mut v = [1, 2, 3, 4];
let _it = v.rchunks_exact_mut(0);
@@ -1397,6 +1411,7 @@ fn test_box_slice_clone() {
#[test]
#[allow(unused_must_use)] // here, we care about the side effects of `.clone()`
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg(not(miri))] // Miri does not support panics
fn test_box_slice_clone_panics() {
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -1461,6 +1476,7 @@ fn test_copy_from_slice() {
#[test]
#[should_panic(expected = "destination and source slices have different lengths")]
#[cfg(not(miri))] // Miri does not support panics
fn test_copy_from_slice_dst_longer() {
let src = [0, 1, 2, 3];
let mut dst = [0; 5];
@@ -1469,6 +1485,7 @@ fn test_copy_from_slice_dst_longer() {
#[test]
#[should_panic(expected = "destination and source slices have different lengths")]
#[cfg(not(miri))] // Miri does not support panics
fn test_copy_from_slice_dst_shorter() {
let src = [0, 1, 2, 3];
let mut dst = [0; 3];
@@ -1588,6 +1605,7 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
#[test]
#[cfg_attr(target_os = "emscripten", ignore)] // no threads
#[cfg(not(miri))] // Miri does not support panics
fn panic_safe() {
let prev = panic::take_hook();
panic::set_hook(Box::new(move |info| {

View File

@@ -31,7 +31,6 @@ fn test_rfind() {
}
#[test]
#[cfg(not(miri))]
fn test_collect() {
let empty = "";
let s: String = empty.chars().collect();
@@ -119,7 +118,6 @@ fn test_concat_for_different_types() {
#[test]
fn test_concat_for_different_lengths() {
let empty: &[&str] = &[];
#[cfg(not(miri))]
test_concat!("", empty);
test_concat!("a", ["a"]);
test_concat!("ab", ["a", "b"]);
@@ -148,7 +146,6 @@ fn test_join_for_different_types() {
#[test]
fn test_join_for_different_lengths() {
let empty: &[&str] = &[];
#[cfg(not(miri))]
test_join!("", empty, "-");
test_join!("a", ["a"], "-");
test_join!("a-b", ["a", "b"], "-");
@@ -162,7 +159,6 @@ fn test_join_for_different_lengths_with_long_separator() {
assert_eq!("".len(), 15);
let empty: &[&str] = &[];
#[cfg(not(miri))]
test_join!("", empty, "");
test_join!("a", ["a"], "");
test_join!("ab", ["a", "b"], "");
@@ -170,7 +166,7 @@ fn test_join_for_different_lengths_with_long_separator() {
}
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn test_unsafe_slice() {
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
@@ -243,7 +239,6 @@ fn test_replacen() {
#[test]
fn test_replace() {
let a = "a";
#[cfg(not(miri))]
assert_eq!("".replace(a, "b"), "");
assert_eq!("a".replace(a, "b"), "b");
assert_eq!("ab".replace(a, "b"), "bb");
@@ -303,7 +298,6 @@ fn test_replace_pattern() {
// The current implementation of SliceIndex fails to handle methods
// orthogonally from range types; therefore, it is worth testing
// all of the indexing operations on each input.
#[cfg(not(miri))]
mod slice_index {
// Test a slicing operation **that should succeed,**
// testing it on all of the indexing methods.
@@ -357,6 +351,7 @@ mod slice_index {
// to be used in `should_panic`)
#[test]
#[should_panic(expected = "out of bounds")]
#[cfg(not(miri))] // Miri does not support panics
fn assert_range_eq_can_fail_by_panic() {
assert_range_eq!("abc", 0..5, "abc");
}
@@ -366,6 +361,7 @@ mod slice_index {
// to be used in `should_panic`)
#[test]
#[should_panic(expected = "==")]
#[cfg(not(miri))] // Miri does not support panics
fn assert_range_eq_can_fail_by_inequality() {
assert_range_eq!("abc", 0..2, "abc");
}
@@ -413,6 +409,7 @@ mod slice_index {
#[test]
#[should_panic(expected = $expect_msg)]
#[cfg(not(miri))] // Miri does not support panics
fn index_fail() {
let v: String = $data.into();
let v: &str = &v;
@@ -421,6 +418,7 @@ mod slice_index {
#[test]
#[should_panic(expected = $expect_msg)]
#[cfg(not(miri))] // Miri does not support panics
fn index_mut_fail() {
let mut v: String = $data.into();
let v: &mut str = &mut v;
@@ -490,6 +488,7 @@ mod slice_index {
#[test]
#[cfg(not(target_arch = "asmjs"))] // hits an OOM
#[cfg(not(miri))] // Miri is too slow
fn simple_big() {
fn a_million_letter_x() -> String {
let mut i = 0;
@@ -515,6 +514,7 @@ mod slice_index {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_fail() {
&"中华Việt Nam"[0..2];
}
@@ -666,12 +666,14 @@ mod slice_index {
// check the panic includes the prefix of the sliced string
#[test]
#[should_panic(expected="byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_fail_truncated_1() {
&LOREM_PARAGRAPH[..1024];
}
// check the truncation in the panic message
#[test]
#[should_panic(expected="luctus, im`[...]")]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_fail_truncated_2() {
&LOREM_PARAGRAPH[..1024];
}
@@ -686,7 +688,7 @@ fn test_str_slice_rangetoinclusive_ok() {
#[test]
#[should_panic]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn test_str_slice_rangetoinclusive_notok() {
let s = "abcαβγ";
&s[..=3];
@@ -702,7 +704,7 @@ fn test_str_slicemut_rangetoinclusive_ok() {
#[test]
#[should_panic]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn test_str_slicemut_rangetoinclusive_notok() {
let mut s = "abcαβγ".to_owned();
let s: &mut str = &mut s;
@@ -892,7 +894,7 @@ fn test_as_bytes() {
#[test]
#[should_panic]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn test_as_bytes_fail() {
// Don't double free. (I'm not sure if this exercises the
// original problem code path anymore.)
@@ -982,7 +984,7 @@ fn test_split_at_mut() {
#[test]
#[should_panic]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn test_split_at_boundscheck() {
let s = "ศไทย中华Việt Nam";
s.split_at(1);
@@ -1078,7 +1080,7 @@ fn test_rev_iterator() {
}
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn test_chars_decoding() {
let mut bytes = [0; 4];
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1090,7 +1092,7 @@ fn test_chars_decoding() {
}
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn test_chars_rev_decoding() {
let mut bytes = [0; 4];
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1320,7 +1322,6 @@ fn test_splitator() {
}
#[test]
#[cfg(not(miri))]
fn test_str_default() {
use std::default::Default;
@@ -1380,7 +1381,7 @@ fn test_bool_from_str() {
assert_eq!("not even a boolean".parse::<bool>().ok(), None);
}
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn check_contains_all_substrings(s: &str) {
assert!(s.contains(""));
for i in 0..s.len() {
@@ -1391,7 +1392,7 @@ fn check_contains_all_substrings(s: &str) {
}
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn strslice_issue_16589() {
assert!("bananas".contains("nana"));
@@ -1401,7 +1402,6 @@ fn strslice_issue_16589() {
}
#[test]
#[cfg(not(miri))]
fn strslice_issue_16878() {
assert!(!"1234567ah012345678901ah".contains("hah"));
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
@@ -1409,7 +1409,7 @@ fn strslice_issue_16878() {
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn test_strslice_contains() {
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
check_contains_all_substrings(x);
@@ -1547,7 +1547,6 @@ fn trim_ws() {
#[test]
fn to_lowercase() {
#[cfg(not(miri))]
assert_eq!("".to_lowercase(), "");
assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé ");
@@ -1581,7 +1580,6 @@ fn to_lowercase() {
#[test]
fn to_uppercase() {
#[cfg(not(miri))]
assert_eq!("".to_uppercase(), "");
assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ");
}
@@ -1613,7 +1611,6 @@ fn test_cow_from() {
}
#[test]
#[cfg(not(miri))]
fn test_repeat() {
assert_eq!("".repeat(3), "");
assert_eq!("abc".repeat(0), "");

View File

@@ -1,5 +1,3 @@
#![cfg(not(miri))]
use std::borrow::Cow;
use std::collections::CollectionAllocErr::*;
use std::mem::size_of;
@@ -233,6 +231,7 @@ fn test_split_off_empty() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_split_off_past_end() {
let orig = "Hello, world!";
let mut split = String::from(orig);
@@ -241,6 +240,7 @@ fn test_split_off_past_end() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_split_off_mid_char() {
let mut orig = String::from("");
orig.split_off(1);
@@ -289,6 +289,7 @@ fn test_str_truncate_invalid_len() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_str_truncate_split_codepoint() {
let mut s = String::from("\u{FC}"); // ü
s.truncate(1);
@@ -323,6 +324,7 @@ fn remove() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn remove_bad() {
"".to_string().remove(1);
}
@@ -358,11 +360,13 @@ fn insert() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn insert_bad1() {
"".to_string().insert(1, 't');
}
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn insert_bad2() {
"".to_string().insert(1, 't');
}
@@ -443,6 +447,7 @@ fn test_replace_range() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_replace_range_char_boundary() {
let mut s = "Hello, 世界!".to_owned();
s.replace_range(..8, "");
@@ -459,6 +464,7 @@ fn test_replace_range_inclusive_range() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_replace_range_out_of_bounds() {
let mut s = String::from("12345");
s.replace_range(5..6, "789");
@@ -466,6 +472,7 @@ fn test_replace_range_out_of_bounds() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_replace_range_inclusive_out_of_bounds() {
let mut s = String::from("12345");
s.replace_range(5..=5, "789");
@@ -525,6 +532,7 @@ fn test_reserve_exact() {
}
#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
fn test_try_reserve() {
// These are the interesting cases:
@@ -602,6 +610,7 @@ fn test_try_reserve() {
}
#[test]
#[cfg(not(miri))] // Miri does not support signalling OOM
fn test_try_reserve_exact() {
// This is exactly the same as test_try_reserve with the method changed.

View File

@@ -368,6 +368,7 @@ fn test_vec_truncate_drop() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_vec_truncate_fail() {
struct BadElem(i32);
impl Drop for BadElem {
@@ -391,6 +392,7 @@ fn test_index() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_index_out_of_bounds() {
let vec = vec![1, 2, 3];
let _ = vec[3];
@@ -398,6 +400,7 @@ fn test_index_out_of_bounds() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_out_of_bounds_1() {
let x = vec![1, 2, 3, 4, 5];
&x[!0..];
@@ -405,6 +408,7 @@ fn test_slice_out_of_bounds_1() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_out_of_bounds_2() {
let x = vec![1, 2, 3, 4, 5];
&x[..6];
@@ -412,6 +416,7 @@ fn test_slice_out_of_bounds_2() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_out_of_bounds_3() {
let x = vec![1, 2, 3, 4, 5];
&x[!0..4];
@@ -419,6 +424,7 @@ fn test_slice_out_of_bounds_3() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_out_of_bounds_4() {
let x = vec![1, 2, 3, 4, 5];
&x[1..6];
@@ -426,6 +432,7 @@ fn test_slice_out_of_bounds_4() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_slice_out_of_bounds_5() {
let x = vec![1, 2, 3, 4, 5];
&x[3..2];
@@ -433,6 +440,7 @@ fn test_slice_out_of_bounds_5() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_swap_remove_empty() {
let mut vec = Vec::<i32>::new();
vec.swap_remove(0);
@@ -503,6 +511,7 @@ fn test_drain_items_zero_sized() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_drain_out_of_bounds() {
let mut v = vec![1, 2, 3, 4, 5];
v.drain(5..6);
@@ -576,6 +585,7 @@ fn test_drain_max_vec_size() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_drain_inclusive_out_of_bounds() {
let mut v = vec![1, 2, 3, 4, 5];
v.drain(5..=5);
@@ -605,6 +615,7 @@ fn test_splice_inclusive_range() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_splice_out_of_bounds() {
let mut v = vec![1, 2, 3, 4, 5];
let a = [10, 11, 12];
@@ -613,6 +624,7 @@ fn test_splice_out_of_bounds() {
#[test]
#[should_panic]
#[cfg(not(miri))] // Miri does not support panics
fn test_splice_inclusive_out_of_bounds() {
let mut v = vec![1, 2, 3, 4, 5];
let a = [10, 11, 12];

View File

@@ -108,7 +108,7 @@ fn test_index() {
#[test]
#[should_panic]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support panics
fn test_index_out_of_bounds() {
let mut deq = VecDeque::new();
for i in 1..4 {
@@ -907,24 +907,20 @@ fn test_append() {
// normal append
a.append(&mut b);
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
#[cfg(not(miri))]
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
// append nothing to something
a.append(&mut b);
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
#[cfg(not(miri))]
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
// append something to nothing
b.append(&mut a);
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
#[cfg(not(miri))]
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), []);
}
#[test]
#[cfg(not(miri))]
fn test_append_permutations() {
fn construct_vec_deque(
push_back: usize,
@@ -948,7 +944,10 @@ fn test_append_permutations() {
out
}
#[cfg(not(miri))] // Miri is too slow
const MAX: usize = 5;
#[cfg(miri)]
const MAX: usize = 3;
// Many different permutations of both the `VecDeque` getting appended to
// and the one getting appended are generated to check `append`.
@@ -1125,7 +1124,7 @@ fn test_reserve_exact_2() {
}
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support signalling OOM
fn test_try_reserve() {
// These are the interesting cases:
@@ -1227,7 +1226,7 @@ fn test_try_reserve() {
}
#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri does not support signalling OOM
fn test_try_reserve_exact() {
// This is exactly the same as test_try_reserve with the method changed.