diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 073f16e354d3a4eada298ca9503a4e1c9c66e17a..2837c923b3d5b67ae749a4adf4ffd363fed11d17 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -332,7 +332,7 @@ pub fn make_test(config: &Config, testfile: &Path, f: F) -> test::TestDescAnd desc: test::TestDesc { name: make_test_name(config, testfile), ignore: header::is_test_ignored(config, testfile), - should_fail: test::ShouldFail::No, + should_panic: test::ShouldPanic::No, }, testfn: f(), } diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 01fb8e3587240ecd6b342c67605e96d869013744..d08c9b3257a01bd01582980e0f3cc1cd9c5938ad 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -323,7 +323,7 @@ fn test_arena_destructors() { } #[test] -#[should_fail] +#[should_panic] fn test_arena_destructors_fail() { let arena = Arena::new(); // Put some stuff in the arena. diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index 4c966c0d44b4d992ab833029f88735d6c339855d..68ff94cfbfb942f33ec251dceee5941156f5a90b 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -490,7 +490,7 @@ fn test_operators() { } #[test] - #[should_fail] + #[should_panic] fn test_overflow() { #[allow(dead_code)] #[derive(Copy)] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index abcb996e3ede1478ee7498d9917d8b29216b549b..cffa4bbfbf41134bf12a04d9ed8163bb88ade7a4 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1647,14 +1647,14 @@ fn test_tail_mut() { } #[test] - #[should_fail] + #[should_panic] fn test_tail_empty() { let a = Vec::::new(); a.tail(); } #[test] - #[should_fail] + #[should_panic] fn test_tail_mut_empty() { let mut a = Vec::::new(); a.tail_mut(); @@ -1681,14 +1681,14 @@ fn test_init_mut() { } #[test] - #[should_fail] + #[should_panic] fn test_init_empty() { let a = Vec::::new(); a.init(); } #[test] - #[should_fail] + #[should_panic] fn test_init_mut_empty() { let mut a = Vec::::new(); a.init_mut(); @@ -1790,7 +1790,7 @@ fn test_swap_remove() { } #[test] - #[should_fail] + #[should_panic] fn test_swap_remove_fail() { let mut v = vec![1]; let _ = v.swap_remove(0); @@ -2205,7 +2205,7 @@ fn test_insert() { } #[test] - #[should_fail] + #[should_panic] fn test_insert_oob() { let mut a = vec![1, 2, 3]; a.insert(4, 5); @@ -2229,7 +2229,7 @@ fn test_remove() { } #[test] - #[should_fail] + #[should_panic] fn test_remove_fail() { let mut a = vec![1]; let _ = a.remove(0); @@ -2253,7 +2253,7 @@ fn test_slice_2() { } #[test] - #[should_fail] + #[should_panic] fn test_permute_fail() { let v: [(Box<_>, Rc<_>); 4] = [(box 0, Rc::new(0)), (box 0, Rc::new(0)), @@ -2528,7 +2528,7 @@ fn test_windowsator() { } #[test] - #[should_fail] + #[should_panic] fn test_windowsator_0() { let v = &[1,2,3,4]; let _it = v.windows(0); @@ -2564,7 +2564,7 @@ fn test_chunksator() { } #[test] - #[should_fail] + #[should_panic] fn test_chunksator_0() { let v = &[1,2,3,4]; let _it = v.chunks(0); @@ -2647,7 +2647,7 @@ fn test_bytes_set_memory() { } #[test] - #[should_fail] + #[should_panic] fn test_overflow_does_not_cause_segfault() { let mut v = vec![]; v.reserve_exact(-1); @@ -2656,7 +2656,7 @@ fn test_overflow_does_not_cause_segfault() { } #[test] - #[should_fail] + #[should_panic] fn test_overflow_does_not_cause_segfault_managed() { let mut v = vec![Rc::new(1)]; v.reserve_exact(-1); @@ -2833,7 +2833,7 @@ fn test_mut_chunks_rev() { } #[test] - #[should_fail] + #[should_panic] fn test_mut_chunks_0() { let mut v = [1, 2, 3, 4]; let _it = v.chunks_mut(0); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 99547b9c60a8974e1c2e5fe316c42e33e813374b..49317a7f0cecdfab20de2a20dc69c1668d9dc556 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1877,7 +1877,7 @@ fn test_slice_2() { } #[test] - #[should_fail] + #[should_panic] fn test_slice_fail() { "中华Việt Nam".slice(0, 2); } @@ -2095,7 +2095,7 @@ fn test_as_bytes() { } #[test] - #[should_fail] + #[should_panic] fn test_as_bytes_fail() { // Don't double free. (I'm not sure if this exercises the // original problem code path anymore.) @@ -2132,7 +2132,7 @@ fn test_subslice_offset() { } #[test] - #[should_fail] + #[should_panic] fn test_subslice_offset_2() { let a = "alchemiter"; let b = "cruxtruder"; diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index d6ec8f0d979e0cde74402f03afdcc9dfa10cdb3f..a34193a4d2c85f1fd32fb62dd239ee99a7b6f712 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1232,14 +1232,14 @@ fn test_str_truncate() { } #[test] - #[should_fail] + #[should_panic] fn test_str_truncate_invalid_len() { let mut s = String::from_str("12345"); s.truncate(6); } #[test] - #[should_fail] + #[should_panic] fn test_str_truncate_split_codepoint() { let mut s = String::from_str("\u{FC}"); // ü s.truncate(1); @@ -1272,7 +1272,7 @@ fn remove() { assert_eq!(s, "ไทย中华Vit Nam; foobar"); } - #[test] #[should_fail] + #[test] #[should_panic] fn remove_bad() { "ศ".to_string().remove(1); } @@ -1286,8 +1286,8 @@ fn insert() { assert_eq!(s, "ệfooยbar"); } - #[test] #[should_fail] fn insert_bad1() { "".to_string().insert(1, 't'); } - #[test] #[should_fail] fn insert_bad2() { "ệ".to_string().insert(1, 't'); } + #[test] #[should_panic] fn insert_bad1() { "".to_string().insert(1, 't'); } + #[test] #[should_panic] fn insert_bad2() { "ệ".to_string().insert(1, 't'); } #[test] fn test_slicing() { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 2e947ea24602aafdedb64848032d87ab8b53dc6a..ca0092a6e66ddb942c07d2b2b0cb8c55d6c38776 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -2242,7 +2242,7 @@ fn drop(&mut self) { } #[test] - #[should_fail] + #[should_panic] fn test_vec_truncate_fail() { struct BadElem(i32); impl Drop for BadElem { @@ -2265,49 +2265,49 @@ fn test_index() { } #[test] - #[should_fail] + #[should_panic] fn test_index_out_of_bounds() { let vec = vec![1, 2, 3]; let _ = vec[3]; } #[test] - #[should_fail] + #[should_panic] fn test_slice_out_of_bounds_1() { let x = vec![1, 2, 3, 4, 5]; &x[-1..]; } #[test] - #[should_fail] + #[should_panic] fn test_slice_out_of_bounds_2() { let x = vec![1, 2, 3, 4, 5]; &x[..6]; } #[test] - #[should_fail] + #[should_panic] fn test_slice_out_of_bounds_3() { let x = vec![1, 2, 3, 4, 5]; &x[-1..4]; } #[test] - #[should_fail] + #[should_panic] fn test_slice_out_of_bounds_4() { let x = vec![1, 2, 3, 4, 5]; &x[1..6]; } #[test] - #[should_fail] + #[should_panic] fn test_slice_out_of_bounds_5() { let x = vec![1, 2, 3, 4, 5]; &x[3..2]; } #[test] - #[should_fail] + #[should_panic] fn test_swap_remove_empty() { let mut vec= Vec::::new(); vec.swap_remove(0); @@ -2326,7 +2326,7 @@ fn test_move_iter_unwrap() { } #[test] - #[should_fail] + #[should_panic] fn test_map_in_place_incompatible_types_fail() { let v = vec![0, 1, 2]; v.map_in_place(|_| ()); diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 551d28b91b4bf02a2f38a30f7ead39f35f143728..cab589d55beae584a18385f4911fb2830a72c959 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -1884,7 +1884,7 @@ fn test_index() { } #[test] - #[should_fail] + #[should_panic] fn test_index_out_of_bounds() { let mut deq = VecDeque::new(); for i in 1..4 { diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 515de74e340ac9d5fd6f7b3c78d784a1e05d82a2..431c8d5df8c0a11dfa27efa2394b1a2db30a57a8 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -1432,7 +1432,7 @@ fn test_index() { } #[test] - #[should_fail] + #[should_panic] fn test_index_nonexistent() { let mut map = VecMap::new(); diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index 317ef3a570143e9611f73d3e00047ccbf71c8045..3397cbb18faa09c38284194e5149a95cb7141047 100644 --- a/src/libcoretest/cell.rs +++ b/src/libcoretest/cell.rs @@ -109,7 +109,7 @@ fn double_borrow_single_release_no_borrow_mut() { } #[test] -#[should_fail] +#[should_panic] fn discard_doesnt_unborrow() { let x = RefCell::new(0); let _b = x.borrow(); diff --git a/src/libcoretest/finally.rs b/src/libcoretest/finally.rs index 55fcb8498513c5a804cff7d0cbf3976e0b639171..2a48395271db3804ccb20a0b0c6be55bc67e72f4 100644 --- a/src/libcoretest/finally.rs +++ b/src/libcoretest/finally.rs @@ -30,7 +30,7 @@ fn test_success() { } #[test] -#[should_fail] +#[should_panic] fn test_fail() { let mut i = 0; try_finally( diff --git a/src/libcoretest/fmt/num.rs b/src/libcoretest/fmt/num.rs index bc3995439a0173c782f158f56daa1c835dd3b7ac..7db8db444ff20901b67040498155a4c2196a90a3 100644 --- a/src/libcoretest/fmt/num.rs +++ b/src/libcoretest/fmt/num.rs @@ -161,7 +161,7 @@ fn test_format_radix() { } #[test] -#[should_fail] +#[should_panic] fn test_radix_base_too_large() { let _ = radix(55, 37); } diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 91d1ea2747657efb1d8ae45ee370981354a7f79b..0f4e7fcdda57bdb3469316492c823aa141acbdd9 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -581,7 +581,7 @@ fn test_rposition() { } #[test] -#[should_fail] +#[should_panic] fn test_rposition_panic() { let v: [(Box<_>, Box<_>); 4] = [(box 0, box 0), (box 0, box 0), diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 59116f23d44b64ab7dbe50ba8e69702d4c557e41..fe0b10e91192bce5c1b62e288d0b0c9df9ffc748 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -80,7 +80,7 @@ fn test_option_dance() { assert!(y.is_none()); } -#[test] #[should_fail] +#[test] #[should_panic] fn test_option_too_much_dance() { let mut y = Some(marker::NoCopy); let _y2 = y.take().unwrap(); @@ -139,14 +139,14 @@ fn test_unwrap() { } #[test] -#[should_fail] +#[should_panic] fn test_unwrap_panic1() { let x: Option = None; x.unwrap(); } #[test] -#[should_fail] +#[should_panic] fn test_unwrap_panic2() { let x: Option = None; x.unwrap(); diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs index 10cc3ad64242720e59c2d5e9682a09d8f6aab45d..1c175ba99f7739619bd7c7b90148666d27c41052 100644 --- a/src/libcoretest/result.rs +++ b/src/libcoretest/result.rs @@ -126,7 +126,7 @@ fn handler(msg: &'static str) -> int { } #[test] -#[should_fail] +#[should_panic] pub fn test_unwrap_or_else_panic() { fn handler(msg: &'static str) -> int { if msg == "I got this." { diff --git a/src/librand/distributions/exponential.rs b/src/librand/distributions/exponential.rs index e4927902cb3bb66184ad59f4c360818ee39491af..bf9d334e8a4734bf7814d31fdf5a30f49a458808 100644 --- a/src/librand/distributions/exponential.rs +++ b/src/librand/distributions/exponential.rs @@ -109,12 +109,12 @@ fn test_exp() { } } #[test] - #[should_fail] + #[should_panic] fn test_exp_invalid_lambda_zero() { Exp::new(0.0); } #[test] - #[should_fail] + #[should_panic] fn test_exp_invalid_lambda_neg() { Exp::new(-10.0); } diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs index 38eba0cfc712f7221961113775972f80ad76cdc0..ae3724a2b431a1ca371465ced275fd5dfb13d88b 100644 --- a/src/librand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -356,7 +356,7 @@ fn test_chi_squared_large() { } } #[test] - #[should_fail] + #[should_panic] fn test_chi_squared_invalid_dof() { ChiSquared::new(-1.0); } diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 12794ed69be38c7edd263b879969342f02a673bb..9775507b3cd578b38abd7c1225da82d0b8162369 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -351,16 +351,16 @@ fn test_weighted_choice() { [50, 51, 52, 53, 54, 55, 56]); } - #[test] #[should_fail] + #[test] #[should_panic] fn test_weighted_choice_no_items() { WeightedChoice::::new(&mut []); } - #[test] #[should_fail] + #[test] #[should_panic] fn test_weighted_choice_zero_weight() { WeightedChoice::new(&mut [Weighted { weight: 0, item: 0}, Weighted { weight: 0, item: 1}]); } - #[test] #[should_fail] + #[test] #[should_panic] fn test_weighted_choice_weight_overflows() { let x = (-1) as uint / 2; // x + x + 2 is the overflow WeightedChoice::new(&mut [Weighted { weight: x, item: 0 }, diff --git a/src/librand/distributions/normal.rs b/src/librand/distributions/normal.rs index 83f202742d3f33da9dbdf016c32b1cbe541f93ce..ab5d03ad82557adfe8fbf28eca8dbd5d13df47e0 100644 --- a/src/librand/distributions/normal.rs +++ b/src/librand/distributions/normal.rs @@ -175,7 +175,7 @@ fn test_normal() { } } #[test] - #[should_fail] + #[should_panic] fn test_normal_invalid_sd() { Normal::new(10.0, -1.0); } @@ -191,7 +191,7 @@ fn test_log_normal() { } } #[test] - #[should_fail] + #[should_panic] fn test_log_normal_invalid_sd() { LogNormal::new(10.0, -1.0); } diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index 4afc67d63c8f952c4ef4405016cb23a19874d56e..c5a260346e0adf17dc464bb62a57d4313d3e1e82 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -169,12 +169,12 @@ mod tests { use distributions::{Sample, IndependentSample}; use super::Range as Range; - #[should_fail] + #[should_panic] #[test] fn test_range_bad_limits_equal() { Range::new(10, 10); } - #[should_fail] + #[should_panic] #[test] fn test_range_bad_limits_flipped() { Range::new(10, 5); diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index 482c710149c0920a3d5ce7103ff955dbf8504cfd..1a399519296a829ecd782994096376ff890a392b 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -548,7 +548,7 @@ fn test_add_bytes_to_bits_ok() { // A simple failure case - adding 1 to the max value #[test] - #[should_fail] + #[should_panic] fn test_add_bytes_to_bits_overflow() { super::add_bytes_to_bits::(Int::max_value(), 1); } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index c785d78dc9303e1247e87298cc9fca6c2adcc899..e7312d6548e9f5798a811923818389ecad43b141 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -114,7 +114,7 @@ pub fn run(input: &str, #[allow(deprecated)] fn runtest(test: &str, cratename: &str, libs: SearchPaths, externs: core::Externs, - should_fail: bool, no_run: bool, as_test_harness: bool) { + should_panic: bool, no_run: bool, as_test_harness: bool) { // the test harness wants its own `main` & top level functions, so // never wrap the test in `fn main() { ... }` let test = maketest(test, Some(cratename), true, as_test_harness); @@ -210,9 +210,9 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths, " - maybe your tempdir is mounted with noexec?" } else { "" }), Ok(out) => { - if should_fail && out.status.success() { + if should_panic && out.status.success() { panic!("test executable succeeded when it should have failed"); - } else if !should_fail && !out.status.success() { + } else if !should_panic && !out.status.success() { panic!("test executable failed:\n{:?}", str::from_utf8(&out.stdout)); } @@ -279,7 +279,7 @@ pub fn new(cratename: String, libs: SearchPaths, externs: core::Externs, } pub fn add_test(&mut self, test: String, - should_fail: bool, no_run: bool, should_ignore: bool, as_test_harness: bool) { + should_panic: bool, no_run: bool, should_ignore: bool, as_test_harness: bool) { let name = if self.use_headers { let s = self.current_header.as_ref().map(|s| &**s).unwrap_or(""); format!("{}_{}", s, self.cnt) @@ -295,14 +295,14 @@ pub fn add_test(&mut self, test: String, desc: testing::TestDesc { name: testing::DynTestName(name), ignore: should_ignore, - should_fail: testing::ShouldFail::No, // compiler failures are test failures + should_panic: testing::ShouldPanic::No, // compiler failures are test failures }, testfn: testing::DynTestFn(Thunk::new(move|| { runtest(&test, &cratename, libs, externs, - should_fail, + should_panic, no_run, as_test_harness); })) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 8eb29a8327a52710c6479f026e35bc4a698b516e..9502302aa53ab8de04827a7af22e91b23bc8d93e 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2197,7 +2197,7 @@ fn test_index() { } #[test] - #[should_fail] + #[should_panic] fn test_index_nonexistent() { let mut map = HashMap::new(); diff --git a/src/libstd/old_io/buffered.rs b/src/libstd/old_io/buffered.rs index fe2510b668f9278e6376734a13804e90ab082b68..cbb7bf043274506cee50a88ae535ac30f79711e2 100644 --- a/src/libstd/old_io/buffered.rs +++ b/src/libstd/old_io/buffered.rs @@ -658,7 +658,7 @@ fn test_chars() { } #[test] - #[should_fail] + #[should_panic] fn dont_panic_in_drop_on_panicked_flush() { struct FailFlushWriter; diff --git a/src/libstd/old_io/extensions.rs b/src/libstd/old_io/extensions.rs index a2bc28962c39a9ad6b7c38619940c8b49c4445d9..ec30121d78db807afbab0b9495dccd6ce7f4b204 100644 --- a/src/libstd/old_io/extensions.rs +++ b/src/libstd/old_io/extensions.rs @@ -396,7 +396,7 @@ fn read_to_end() { } #[test] - #[should_fail] + #[should_panic] fn read_to_end_error() { let mut reader = ThreeChunkReader { count: 0, diff --git a/src/libstd/old_io/timer.rs b/src/libstd/old_io/timer.rs index de5f2141095f30705e99a467f9c5b16e746a04d6..375fe6ce483aae520dbb3236ce0bbf75c0af3d15 100644 --- a/src/libstd/old_io/timer.rs +++ b/src/libstd/old_io/timer.rs @@ -333,7 +333,7 @@ fn sleep() { } #[test] - #[should_fail] + #[should_panic] fn oneshot_fail() { let mut timer = Timer::new().unwrap(); let _rx = timer.oneshot(Duration::milliseconds(1)); @@ -341,7 +341,7 @@ fn oneshot_fail() { } #[test] - #[should_fail] + #[should_panic] fn period_fail() { let mut timer = Timer::new().unwrap(); let _rx = timer.periodic(Duration::milliseconds(1)); @@ -349,7 +349,7 @@ fn period_fail() { } #[test] - #[should_fail] + #[should_panic] fn normal_fail() { let _timer = Timer::new().unwrap(); panic!(); diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs index 31a8cbe572a0318d60d8c0afb8f2c710d205cd11..5f2f1728be1a6317a65792f4be1f1351f89ec58c 100644 --- a/src/libstd/old_path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -1324,7 +1324,7 @@ fn test_null_byte() { } #[test] - #[should_fail] + #[should_panic] fn test_not_utf8_panics() { Path::new(b"hello\x80.txt"); } diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 4ed1520ed03f60181a2651d83287e4a3baf46ebe..7382cc6e2eb33cd1f19fb15e21593ac01247ca11 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -500,14 +500,14 @@ fn test_gen_range() { } #[test] - #[should_fail] + #[should_panic] fn test_gen_range_panic_int() { let mut r = thread_rng(); r.gen_range(5, -2); } #[test] - #[should_fail] + #[should_panic] fn test_gen_range_panic_uint() { let mut r = thread_rng(); r.gen_range(5, 2); diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index ba1ebc2ab227556ce7eb023ae972c85aff5b93ee..c56dc387b7fe6773fa0c69ad0188242c729e3974 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -114,7 +114,7 @@ fn test_reader_rng_fill_bytes() { } #[test] - #[should_fail] + #[should_panic] fn test_reader_rng_insufficient_bytes() { let mut rng = ReaderRng::new(MemReader::new(vec!())); let mut v = [0; 3]; diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index e7ee9bd2066514f4e47a04b3bf2eb102de874fc6..3499675f5422d81c508f37c405ae3ecbc4c5c05b 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -479,7 +479,7 @@ fn wait_timeout_with() { } #[test] - #[should_fail] + #[should_panic] fn two_mutexes() { static M1: StaticMutex = MUTEX_INIT; static M2: StaticMutex = MUTEX_INIT; diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index d60e27388086444a4323c8f53525a8046b28ecec..ee9bcd3dd89bf630d28886e8357f62ea41297def 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -204,7 +204,7 @@ fn test_spawn() { } #[test] - #[should_fail] + #[should_panic] fn test_future_panic() { let mut f = Future::spawn(move|| panic!()); let _x: String = f.get(); diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index efb6689e7855a40da3f9d374ead25439b9bee138..e41bc6d8683abb14a32df9de279ace42423ad01b 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -164,7 +164,7 @@ fn test_works() { } #[test] - #[should_fail] + #[should_panic] fn test_zero_tasks_panic() { TaskPool::new(0); } diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 719c74179ac23690bc360f5bf59e4a7e6c7784c0..7a02df23b19c5659a287d06dceab3c16a7b23a6d 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -1030,14 +1030,14 @@ fn wtf8buf_truncate() { } #[test] - #[should_fail] + #[should_panic] fn wtf8buf_truncate_fail_code_point_boundary() { let mut string = Wtf8Buf::from_str("aé"); string.truncate(2); } #[test] - #[should_fail] + #[should_panic] fn wtf8buf_truncate_fail_longer() { let mut string = Wtf8Buf::from_str("aé"); string.truncate(4); @@ -1133,7 +1133,7 @@ fn wtf8_slice() { } #[test] - #[should_fail] + #[should_panic] fn wtf8_slice_not_code_point_boundary() { &Wtf8::from_str("aé 💩")[2.. 4]; } @@ -1144,7 +1144,7 @@ fn wtf8_slice_from() { } #[test] - #[should_fail] + #[should_panic] fn wtf8_slice_from_not_code_point_boundary() { &Wtf8::from_str("aé 💩")[2..]; } @@ -1155,7 +1155,7 @@ fn wtf8_slice_to() { } #[test] - #[should_fail] + #[should_panic] fn wtf8_slice_to_not_code_point_boundary() { &Wtf8::from_str("aé 💩")[5..]; } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 44df8a6d3daec74139a3b91e3aa234ebf4da2a1d..7d2d4e53fe9fd43002db11920e775e60bfa7b06a 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -922,7 +922,7 @@ fn t1 () { } #[test] - #[should_fail] + #[should_panic] fn t2 () { let cm = CodeMap::new(); let fm = cm.new_filemap("blork.rs".to_string(), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index db8819ef82c2e3f011384141a3a858fbce8d870c..98c7aefcd8ad3275f68122308e65b87d790b441e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1656,7 +1656,7 @@ fn test_ecfg() -> ExpansionConfig<'static> { } // make sure that macros can't escape fns - #[should_fail] + #[should_panic] #[test] fn macros_cant_escape_fns_test () { let src = "fn bogus() {macro_rules! z (() => (3+4));}\ fn inty() -> i32 { z!() }".to_string(); @@ -1670,7 +1670,7 @@ fn test_ecfg() -> ExpansionConfig<'static> { } // make sure that macros can't escape modules - #[should_fail] + #[should_panic] #[test] fn macros_cant_escape_mods_test () { let src = "mod foo {macro_rules! z (() => (3+4));}\ fn inty() -> i32 { z!() }".to_string(); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 58d58551df363715365f717735e0770acbe13284..fae305f955174241d46b018609fbfd5a521c50f2 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -813,7 +813,7 @@ fn sp(a: u32, b: u32) -> Span { })) } - #[should_fail] + #[should_panic] #[test] fn bad_path_expr_1() { string_to_expr("::abc::def::return".to_string()); } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index d889453a5f977127708805124cf273979392a68c..5e858d8a79f766b3750fa6b1b4eaee7176d3c8d4 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -37,7 +37,7 @@ use ptr::P; use util::small_vector::SmallVector; -enum ShouldFail { +enum ShouldPanic { No, Yes(Option), } @@ -47,7 +47,7 @@ struct Test { path: Vec , bench: bool, ignore: bool, - should_fail: ShouldFail + should_panic: ShouldPanic } struct TestCtxt<'a> { @@ -136,7 +136,7 @@ fn fold_item(&mut self, i: P) -> SmallVector> { path: self.cx.path.clone(), bench: is_bench_fn(&self.cx, &*i), ignore: is_ignored(&*i), - should_fail: should_fail(&*i) + should_panic: should_panic(&*i, self.cx.span_diagnostic) }; self.cx.testfns.push(test); self.tests.push(i.ident); @@ -378,15 +378,23 @@ fn is_ignored(i: &ast::Item) -> bool { i.attrs.iter().any(|attr| attr.check_name("ignore")) } -fn should_fail(i: &ast::Item) -> ShouldFail { - match i.attrs.iter().find(|attr| attr.check_name("should_fail")) { +fn should_panic(i: &ast::Item, diag: &diagnostic::SpanHandler) -> ShouldPanic { + match i.attrs.iter().find(|attr| { + if attr.check_name("should_panic") { return true; } + if attr.check_name("should_fail") { + diag.span_warn(attr.span, "`#[should_fail]` is deprecated. Use `#[should_panic]` \ + instead"); + return true; + } + false + }) { Some(attr) => { let msg = attr.meta_item_list() .and_then(|list| list.iter().find(|mi| mi.check_name("expected"))) .and_then(|mi| mi.value_str()); - ShouldFail::Yes(msg) + ShouldPanic::Yes(msg) } - None => ShouldFail::No, + None => ShouldPanic::No, } } @@ -617,13 +625,13 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P { vec![name_expr]); let ignore_expr = ecx.expr_bool(span, test.ignore); - let should_fail_path = |name| { - ecx.path(span, vec![self_id, test_id, ecx.ident_of("ShouldFail"), ecx.ident_of(name)]) + let should_panic_path = |name| { + ecx.path(span, vec![self_id, test_id, ecx.ident_of("ShouldPanic"), ecx.ident_of(name)]) }; - let fail_expr = match test.should_fail { - ShouldFail::No => ecx.expr_path(should_fail_path("No")), - ShouldFail::Yes(ref msg) => { - let path = should_fail_path("Yes"); + let fail_expr = match test.should_panic { + ShouldPanic::No => ecx.expr_path(should_panic_path("No")), + ShouldPanic::Yes(ref msg) => { + let path = should_panic_path("Yes"); let arg = match *msg { Some(ref msg) => ecx.expr_some(span, ecx.expr_str(span, msg.clone())), None => ecx.expr_none(span), @@ -638,7 +646,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P { test_path("TestDesc"), vec![field("name", name_expr), field("ignore", ignore_expr), - field("should_fail", fail_expr)]); + field("should_panic", fail_expr)]); let mut visible_path = match cx.toplevel_reexport { diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 5be45a2698f40ae34c295c3e2e892994d465fc2a..7ae9e4646e516b32bee9972485f904b3f974d2d6 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -234,7 +234,7 @@ mod tests { use ast::Name; #[test] - #[should_fail] + #[should_panic] fn i1 () { let i : Interner = Interner::new(); i.get(Name(13)); diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 90df23882a1d4bf53c790a36ed40dae5ac899696..5bd6591cfb097c770cf1aa658e8e495ad91f4e97 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -236,13 +236,13 @@ fn test_move_iter() { } #[test] - #[should_fail] + #[should_panic] fn test_expect_one_zero() { let _: isize = SmallVector::zero().expect_one(""); } #[test] - #[should_fail] + #[should_panic] fn test_expect_one_many() { SmallVector::many(vec!(1, 2)).expect_one(""); } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index e4e1845de63966fda3e97b6dc5d06293ca634946..1590291c88c16336a492d4a00341f77511f90231 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -90,7 +90,7 @@ pub mod test { Metric, MetricMap, StaticTestFn, StaticTestName, DynTestName, DynTestFn, run_test, test_main, test_main_static, filter_tests, - parse_opts, StaticBenchFn, ShouldFail}; + parse_opts, StaticBenchFn, ShouldPanic}; } pub mod stats; @@ -202,7 +202,7 @@ pub struct Bencher { } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum ShouldFail { +pub enum ShouldPanic { No, Yes(Option<&'static str>) } @@ -213,7 +213,7 @@ pub enum ShouldFail { pub struct TestDesc { pub name: TestName, pub ignore: bool, - pub should_fail: ShouldFail, + pub should_panic: ShouldPanic, } unsafe impl Send for TestDesc {} @@ -351,10 +351,10 @@ fn usage(binary: &str) { takes no arguments. #[bench] - Indicates a function is a benchmark to be run. This function takes one argument (test::Bencher). - #[should_fail] - This function (also labeled with #[test]) will only pass if - the code causes a failure (an assertion failure or panic!) + #[should_panic] - This function (also labeled with #[test]) will only pass if + the code causes a panic (an assertion failure or panic!) A message may be provided, which the failure string must - contain: #[should_fail(expected = "foo")]. + contain: #[should_panic(expected = "foo")]. #[ignore] - When applied to a function which is already attributed as a test, then the test runner will ignore these tests during normal test runs. Running with --ignored will run these @@ -717,13 +717,13 @@ fn should_sort_failures_before_printing_them() { let test_a = TestDesc { name: StaticTestName("a"), ignore: false, - should_fail: ShouldFail::No + should_panic: ShouldPanic::No }; let test_b = TestDesc { name: StaticTestName("b"), ignore: false, - should_fail: ShouldFail::No + should_panic: ShouldPanic::No }; let mut st = ConsoleTestState { @@ -953,10 +953,10 @@ fn run_test_inner(desc: TestDesc, } fn calc_result(desc: &TestDesc, task_result: Result<(), Box>) -> TestResult { - match (&desc.should_fail, task_result) { - (&ShouldFail::No, Ok(())) | - (&ShouldFail::Yes(None), Err(_)) => TrOk, - (&ShouldFail::Yes(Some(msg)), Err(ref err)) + match (&desc.should_panic, task_result) { + (&ShouldPanic::No, Ok(())) | + (&ShouldPanic::Yes(None), Err(_)) => TrOk, + (&ShouldPanic::Yes(Some(msg)), Err(ref err)) if err.downcast_ref::() .map(|e| &**e) .or_else(|| err.downcast_ref::<&'static str>().map(|e| *e)) @@ -1151,7 +1151,7 @@ mod tests { use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, TestDesc, TestDescAndFn, TestOpts, run_test, MetricMap, - StaticTestName, DynTestName, DynTestFn, ShouldFail}; + StaticTestName, DynTestName, DynTestFn, ShouldPanic}; use std::thunk::Thunk; use std::sync::mpsc::channel; @@ -1162,7 +1162,7 @@ pub fn do_not_run_ignored_tests() { desc: TestDesc { name: StaticTestName("whatever"), ignore: true, - should_fail: ShouldFail::No, + should_panic: ShouldPanic::No, }, testfn: DynTestFn(Thunk::new(move|| f())), }; @@ -1179,7 +1179,7 @@ fn f() { } desc: TestDesc { name: StaticTestName("whatever"), ignore: true, - should_fail: ShouldFail::No, + should_panic: ShouldPanic::No, }, testfn: DynTestFn(Thunk::new(move|| f())), }; @@ -1190,13 +1190,13 @@ fn f() { } } #[test] - fn test_should_fail() { + fn test_should_panic() { fn f() { panic!(); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), ignore: false, - should_fail: ShouldFail::Yes(None) + should_panic: ShouldPanic::Yes(None) }, testfn: DynTestFn(Thunk::new(move|| f())), }; @@ -1207,13 +1207,13 @@ fn test_should_fail() { } #[test] - fn test_should_fail_good_message() { + fn test_should_panic_good_message() { fn f() { panic!("an error message"); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), ignore: false, - should_fail: ShouldFail::Yes(Some("error message")) + should_panic: ShouldPanic::Yes(Some("error message")) }, testfn: DynTestFn(Thunk::new(move|| f())), }; @@ -1224,13 +1224,13 @@ fn test_should_fail_good_message() { } #[test] - fn test_should_fail_bad_message() { + fn test_should_panic_bad_message() { fn f() { panic!("an error message"); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), ignore: false, - should_fail: ShouldFail::Yes(Some("foobar")) + should_panic: ShouldPanic::Yes(Some("foobar")) }, testfn: DynTestFn(Thunk::new(move|| f())), }; @@ -1241,13 +1241,13 @@ fn test_should_fail_bad_message() { } #[test] - fn test_should_fail_but_succeeds() { + fn test_should_panic_but_succeeds() { fn f() { } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), ignore: false, - should_fail: ShouldFail::Yes(None) + should_panic: ShouldPanic::Yes(None) }, testfn: DynTestFn(Thunk::new(move|| f())), }; @@ -1283,7 +1283,7 @@ pub fn filter_for_ignored_option() { desc: TestDesc { name: StaticTestName("1"), ignore: true, - should_fail: ShouldFail::No, + should_panic: ShouldPanic::No, }, testfn: DynTestFn(Thunk::new(move|| {})), }, @@ -1291,7 +1291,7 @@ pub fn filter_for_ignored_option() { desc: TestDesc { name: StaticTestName("2"), ignore: false, - should_fail: ShouldFail::No, + should_panic: ShouldPanic::No, }, testfn: DynTestFn(Thunk::new(move|| {})), }); @@ -1327,7 +1327,7 @@ fn testfn() { } desc: TestDesc { name: DynTestName((*name).clone()), ignore: false, - should_fail: ShouldFail::No, + should_panic: ShouldPanic::No, }, testfn: DynTestFn(Thunk::new(testfn)), }; diff --git a/src/test/run-fail/test-should-fail-bad-message.rs b/src/test/run-fail/test-should-fail-bad-message.rs index 5a5bb53a33a209f12f25f928a01fb662e034e7ff..e18c5d9631a702358a6964b918fe8b2db3bb3267 100644 --- a/src/test/run-fail/test-should-fail-bad-message.rs +++ b/src/test/run-fail/test-should-fail-bad-message.rs @@ -14,7 +14,7 @@ // ignore-pretty: does not work well with `--test` #[test] -#[should_fail(expected = "foobar")] +#[should_panic(expected = "foobar")] fn test_foo() { panic!("blah") } diff --git a/src/test/run-pass/test-should-fail-good-message.rs b/src/test/run-pass/test-should-fail-good-message.rs index dcb2fe6dfc07660a78be9646655e93b5df4bf3c8..b8e05b4d35ab78da407efe8174b2d383a2bac5ca 100644 --- a/src/test/run-pass/test-should-fail-good-message.rs +++ b/src/test/run-pass/test-should-fail-good-message.rs @@ -12,13 +12,13 @@ // ignore-pretty: does not work well with `--test` #[test] -#[should_fail(expected = "foo")] +#[should_panic(expected = "foo")] fn test_foo() { panic!("foo bar") } #[test] -#[should_fail(expected = "foo")] +#[should_panic(expected = "foo")] fn test_foo_dynamic() { panic!("{} bar", "foo") }