diff options
| author | Steven Fackler <sfackler@gmail.com> | 2015-01-31 15:08:25 -0800 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2015-03-09 10:14:21 -0700 |
| commit | e2605b42c7ce37717118fe240f7d0e8c4eae3598 (patch) | |
| tree | 29aa2b8718f77fa3e1c04a60e0c8187e021768a7 /src/libsyntax | |
| parent | 2574009af0ff70dc233beab246db8f2d715be2cb (diff) | |
| download | rust-e2605b42c7ce37717118fe240f7d0e8c4eae3598.tar.gz rust-e2605b42c7ce37717118fe240f7d0e8c4eae3598.zip | |
Rename #[should_fail] to #[should_panic]
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 36 | ||||
| -rw-r--r-- | src/libsyntax/util/interner.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 4 |
6 files changed, 29 insertions, 21 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 44df8a6d3da..7d2d4e53fe9 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -922,7 +922,7 @@ mod test { } #[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 db8819ef82c..98c7aefcd8a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1656,7 +1656,7 @@ mod test { } // 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 @@ mod test { } // 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 58d58551df3..fae305f9551 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -813,7 +813,7 @@ mod test { })) } - #[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 d889453a5f9..5e858d8a79f 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -37,7 +37,7 @@ use {ast, ast_util}; use ptr::P; use util::small_vector::SmallVector; -enum ShouldFail { +enum ShouldPanic { No, Yes(Option<InternedString>), } @@ -47,7 +47,7 @@ struct Test { path: Vec<ast::Ident> , bench: bool, ignore: bool, - should_fail: ShouldFail + should_panic: ShouldPanic } struct TestCtxt<'a> { @@ -136,7 +136,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { 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<ast::Expr> { 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<ast::Expr> { 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 5be45a2698f..7ae9e4646e5 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<RcStr> = Interner::new(); i.get(Name(13)); diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 90df23882a1..5bd6591cfb0 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -236,13 +236,13 @@ mod test { } #[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(""); } |
