diff options
| author | Josh Driver <keeperofdakeys@gmail.com> | 2016-11-18 21:01:19 +1030 |
|---|---|---|
| committer | Josh Driver <keeperofdakeys@gmail.com> | 2016-11-18 21:01:19 +1030 |
| commit | fb5ccf80fe83653018794562bfc105d6914384ae (patch) | |
| tree | 8cee96ac32e81a24d6dae4be61b6ac0b3ddccfec /src/test/run-fail | |
| parent | d6689fdc616fd3e7af9946072cb0aaceb2bb26b9 (diff) | |
| download | rust-fb5ccf80fe83653018794562bfc105d6914384ae.tar.gz rust-fb5ccf80fe83653018794562bfc105d6914384ae.zip | |
Warn when a #[should_panic] test has an unexpected message
Diffstat (limited to 'src/test/run-fail')
| -rw-r--r-- | src/test/run-fail/test-should-panic-bad-message.rs | 19 | ||||
| -rw-r--r-- | src/test/run-fail/test-should-panic-no-message.rs | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/run-fail/test-should-panic-bad-message.rs b/src/test/run-fail/test-should-panic-bad-message.rs new file mode 100644 index 00000000000..7186672b404 --- /dev/null +++ b/src/test/run-fail/test-should-panic-bad-message.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --test + +// error-pattern:panicked at 'bar' +// check-stdout +#[test] +#[should_panic(expected = "foo")] +pub fn test_bar() { + panic!("bar") +} diff --git a/src/test/run-fail/test-should-panic-no-message.rs b/src/test/run-fail/test-should-panic-no-message.rs new file mode 100644 index 00000000000..50dc2aed8e9 --- /dev/null +++ b/src/test/run-fail/test-should-panic-no-message.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --test + +// error-pattern:panicked at 'explicit panic' +// check-stdout +#[test] +#[should_panic(expected = "foo")] +pub fn test_explicit() { + panic!() +} |
