Skip to content

Commit b17ca01

Browse files
committed
review failures in binary_heap, str, vec_deque
1 parent e24af6c commit b17ca01

File tree

5 files changed

+23
-33
lines changed

5 files changed

+23
-33
lines changed

src/liballoc/tests/arc.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::any::Any;
42
use std::sync::{Arc, Weak};
53
use std::cell::RefCell;

src/liballoc/tests/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ fn assert_covariance() {
282282
//
283283
// Destructors must be called exactly once per element.
284284
#[test]
285-
#[cfg(not(miri))]
285+
#[cfg(not(miri))] // Miri does not support panics
286286
fn panic_safe() {
287287
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
288288

src/liballoc/tests/rc.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::any::Any;
42
use std::rc::{Rc, Weak};
53
use std::cell::RefCell;

src/liballoc/tests/str.rs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ fn test_rfind() {
3131
}
3232

3333
#[test]
34-
#[cfg(not(miri))]
3534
fn test_collect() {
3635
let empty = "";
3736
let s: String = empty.chars().collect();
@@ -119,7 +118,6 @@ fn test_concat_for_different_types() {
119118
#[test]
120119
fn test_concat_for_different_lengths() {
121120
let empty: &[&str] = &[];
122-
#[cfg(not(miri))]
123121
test_concat!("", empty);
124122
test_concat!("a", ["a"]);
125123
test_concat!("ab", ["a", "b"]);
@@ -148,7 +146,6 @@ fn test_join_for_different_types() {
148146
#[test]
149147
fn test_join_for_different_lengths() {
150148
let empty: &[&str] = &[];
151-
#[cfg(not(miri))]
152149
test_join!("", empty, "-");
153150
test_join!("a", ["a"], "-");
154151
test_join!("a-b", ["a", "b"], "-");
@@ -162,15 +159,14 @@ fn test_join_for_different_lengths_with_long_separator() {
162159
assert_eq!("~~~~~".len(), 15);
163160

164161
let empty: &[&str] = &[];
165-
#[cfg(not(miri))]
166162
test_join!("", empty, "~~~~~");
167163
test_join!("a", ["a"], "~~~~~");
168164
test_join!("a~~~~~b", ["a", "b"], "~~~~~");
169165
test_join!("~~~~~a~~~~~bc", ["", "a", "bc"], "~~~~~");
170166
}
171167

172168
#[test]
173-
#[cfg(not(miri))]
169+
#[cfg(not(miri))] // Miri is too slow
174170
fn test_unsafe_slice() {
175171
assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
176172
assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
@@ -243,7 +239,6 @@ fn test_replacen() {
243239
#[test]
244240
fn test_replace() {
245241
let a = "a";
246-
#[cfg(not(miri))]
247242
assert_eq!("".replace(a, "b"), "");
248243
assert_eq!("a".replace(a, "b"), "b");
249244
assert_eq!("ab".replace(a, "b"), "bb");
@@ -303,7 +298,6 @@ fn test_replace_pattern() {
303298
// The current implementation of SliceIndex fails to handle methods
304299
// orthogonally from range types; therefore, it is worth testing
305300
// all of the indexing operations on each input.
306-
#[cfg(not(miri))]
307301
mod slice_index {
308302
// Test a slicing operation **that should succeed,**
309303
// testing it on all of the indexing methods.
@@ -357,6 +351,7 @@ mod slice_index {
357351
// to be used in `should_panic`)
358352
#[test]
359353
#[should_panic(expected = "out of bounds")]
354+
#[cfg(not(miri))] // Miri does not support panics
360355
fn assert_range_eq_can_fail_by_panic() {
361356
assert_range_eq!("abc", 0..5, "abc");
362357
}
@@ -366,6 +361,7 @@ mod slice_index {
366361
// to be used in `should_panic`)
367362
#[test]
368363
#[should_panic(expected = "==")]
364+
#[cfg(not(miri))] // Miri does not support panics
369365
fn assert_range_eq_can_fail_by_inequality() {
370366
assert_range_eq!("abc", 0..2, "abc");
371367
}
@@ -413,6 +409,7 @@ mod slice_index {
413409

414410
#[test]
415411
#[should_panic(expected = $expect_msg)]
412+
#[cfg(not(miri))] // Miri does not support panics
416413
fn index_fail() {
417414
let v: String = $data.into();
418415
let v: &str = &v;
@@ -421,6 +418,7 @@ mod slice_index {
421418

422419
#[test]
423420
#[should_panic(expected = $expect_msg)]
421+
#[cfg(not(miri))] // Miri does not support panics
424422
fn index_mut_fail() {
425423
let mut v: String = $data.into();
426424
let v: &mut str = &mut v;
@@ -490,6 +488,7 @@ mod slice_index {
490488

491489
#[test]
492490
#[cfg(not(target_arch = "asmjs"))] // hits an OOM
491+
#[cfg(not(miri))] // Miri is too slow
493492
fn simple_big() {
494493
fn a_million_letter_x() -> String {
495494
let mut i = 0;
@@ -515,6 +514,7 @@ mod slice_index {
515514

516515
#[test]
517516
#[should_panic]
517+
#[cfg(not(miri))] // Miri does not support panics
518518
fn test_slice_fail() {
519519
&"中华Việt Nam"[0..2];
520520
}
@@ -666,12 +666,14 @@ mod slice_index {
666666
// check the panic includes the prefix of the sliced string
667667
#[test]
668668
#[should_panic(expected="byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")]
669+
#[cfg(not(miri))] // Miri does not support panics
669670
fn test_slice_fail_truncated_1() {
670671
&LOREM_PARAGRAPH[..1024];
671672
}
672673
// check the truncation in the panic message
673674
#[test]
674675
#[should_panic(expected="luctus, im`[...]")]
676+
#[cfg(not(miri))] // Miri does not support panics
675677
fn test_slice_fail_truncated_2() {
676678
&LOREM_PARAGRAPH[..1024];
677679
}
@@ -686,7 +688,7 @@ fn test_str_slice_rangetoinclusive_ok() {
686688

687689
#[test]
688690
#[should_panic]
689-
#[cfg(not(miri))]
691+
#[cfg(not(miri))] // Miri does not support panics
690692
fn test_str_slice_rangetoinclusive_notok() {
691693
let s = "abcαβγ";
692694
&s[..=3];
@@ -702,7 +704,7 @@ fn test_str_slicemut_rangetoinclusive_ok() {
702704

703705
#[test]
704706
#[should_panic]
705-
#[cfg(not(miri))]
707+
#[cfg(not(miri))] // Miri does not support panics
706708
fn test_str_slicemut_rangetoinclusive_notok() {
707709
let mut s = "abcαβγ".to_owned();
708710
let s: &mut str = &mut s;
@@ -892,7 +894,7 @@ fn test_as_bytes() {
892894

893895
#[test]
894896
#[should_panic]
895-
#[cfg(not(miri))]
897+
#[cfg(not(miri))] // Miri does not support panics
896898
fn test_as_bytes_fail() {
897899
// Don't double free. (I'm not sure if this exercises the
898900
// original problem code path anymore.)
@@ -982,7 +984,7 @@ fn test_split_at_mut() {
982984

983985
#[test]
984986
#[should_panic]
985-
#[cfg(not(miri))]
987+
#[cfg(not(miri))] // Miri does not support panics
986988
fn test_split_at_boundscheck() {
987989
let s = "ศไทย中华Việt Nam";
988990
s.split_at(1);
@@ -1078,7 +1080,7 @@ fn test_rev_iterator() {
10781080
}
10791081

10801082
#[test]
1081-
#[cfg(not(miri))]
1083+
#[cfg(not(miri))] // Miri is too slow
10821084
fn test_chars_decoding() {
10831085
let mut bytes = [0; 4];
10841086
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1090,7 +1092,7 @@ fn test_chars_decoding() {
10901092
}
10911093

10921094
#[test]
1093-
#[cfg(not(miri))]
1095+
#[cfg(not(miri))] // Miri is too slow
10941096
fn test_chars_rev_decoding() {
10951097
let mut bytes = [0; 4];
10961098
for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1320,7 +1322,6 @@ fn test_splitator() {
13201322
}
13211323

13221324
#[test]
1323-
#[cfg(not(miri))]
13241325
fn test_str_default() {
13251326
use std::default::Default;
13261327

@@ -1380,7 +1381,7 @@ fn test_bool_from_str() {
13801381
assert_eq!("not even a boolean".parse::<bool>().ok(), None);
13811382
}
13821383

1383-
#[cfg(not(miri))]
1384+
#[cfg(not(miri))] // Miri is too slow
13841385
fn check_contains_all_substrings(s: &str) {
13851386
assert!(s.contains(""));
13861387
for i in 0..s.len() {
@@ -1391,7 +1392,7 @@ fn check_contains_all_substrings(s: &str) {
13911392
}
13921393

13931394
#[test]
1394-
#[cfg(not(miri))]
1395+
#[cfg(not(miri))] // Miri is too slow
13951396
fn strslice_issue_16589() {
13961397
assert!("bananas".contains("nana"));
13971398

@@ -1401,15 +1402,14 @@ fn strslice_issue_16589() {
14011402
}
14021403

14031404
#[test]
1404-
#[cfg(not(miri))]
14051405
fn strslice_issue_16878() {
14061406
assert!(!"1234567ah012345678901ah".contains("hah"));
14071407
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
14081408
}
14091409

14101410

14111411
#[test]
1412-
#[cfg(not(miri))]
1412+
#[cfg(not(miri))] // Miri is too slow
14131413
fn test_strslice_contains() {
14141414
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
14151415
check_contains_all_substrings(x);
@@ -1547,7 +1547,6 @@ fn trim_ws() {
15471547

15481548
#[test]
15491549
fn to_lowercase() {
1550-
#[cfg(not(miri))]
15511550
assert_eq!("".to_lowercase(), "");
15521551
assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé ");
15531552

@@ -1581,7 +1580,6 @@ fn to_lowercase() {
15811580

15821581
#[test]
15831582
fn to_uppercase() {
1584-
#[cfg(not(miri))]
15851583
assert_eq!("".to_uppercase(), "");
15861584
assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ");
15871585
}
@@ -1613,7 +1611,6 @@ fn test_cow_from() {
16131611
}
16141612

16151613
#[test]
1616-
#[cfg(not(miri))]
16171614
fn test_repeat() {
16181615
assert_eq!("".repeat(3), "");
16191616
assert_eq!("abc".repeat(0), "");

src/liballoc/tests/vec_deque.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn test_index() {
108108

109109
#[test]
110110
#[should_panic]
111-
#[cfg(not(miri))]
111+
#[cfg(not(miri))] // Miri does not support panics
112112
fn test_index_out_of_bounds() {
113113
let mut deq = VecDeque::new();
114114
for i in 1..4 {
@@ -907,24 +907,21 @@ fn test_append() {
907907
// normal append
908908
a.append(&mut b);
909909
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
910-
#[cfg(not(miri))]
911910
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
912911

913912
// append nothing to something
914913
a.append(&mut b);
915914
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
916-
#[cfg(not(miri))]
917915
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
918916

919917
// append something to nothing
920918
b.append(&mut a);
921919
assert_eq!(b.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
922-
#[cfg(not(miri))]
923920
assert_eq!(a.iter().cloned().collect::<Vec<_>>(), []);
924921
}
925922

926923
#[test]
927-
#[cfg(not(miri))]
924+
#[cfg(not(miri))] // Miri is too slow
928925
fn test_append_permutations() {
929926
fn construct_vec_deque(
930927
push_back: usize,
@@ -1125,7 +1122,7 @@ fn test_reserve_exact_2() {
11251122
}
11261123

11271124
#[test]
1128-
#[cfg(not(miri))]
1125+
#[cfg(not(miri))] // Miri does not support signalling OOM
11291126
fn test_try_reserve() {
11301127

11311128
// These are the interesting cases:
@@ -1227,7 +1224,7 @@ fn test_try_reserve() {
12271224
}
12281225

12291226
#[test]
1230-
#[cfg(not(miri))]
1227+
#[cfg(not(miri))] // Miri does not support signalling OOM
12311228
fn test_try_reserve_exact() {
12321229

12331230
// This is exactly the same as test_try_reserve with the method changed.

0 commit comments

Comments
 (0)