about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJosh Driver <keeperofdakeys@gmail.com>2016-11-13 19:39:27 +1030
committerJosh Driver <keeperofdakeys@gmail.com>2016-11-14 22:22:17 +1030
commitd6689fdc616fd3e7af9946072cb0aaceb2bb26b9 (patch)
tree4a78e61ce34cd00ed57d5f4f55b9ad938003c058 /src/test
parenta277f9deb0bcccc096334447b0e57765110707c7 (diff)
downloadrust-d6689fdc616fd3e7af9946072cb0aaceb2bb26b9.tar.gz
rust-d6689fdc616fd3e7af9946072cb0aaceb2bb26b9.zip
Add warnings when the #[should_panic] attribute is invalid
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/test-should-panic-attr.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/run-pass/test-should-panic-attr.rs b/src/test/run-pass/test-should-panic-attr.rs
new file mode 100644
index 00000000000..2d068872a4d
--- /dev/null
+++ b/src/test/run-pass/test-should-panic-attr.rs
@@ -0,0 +1,46 @@
+// Copyright 2016 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
+
+#[test]
+#[should_panic = "foo"]
+//~^ WARN: attribute must be of the form:
+fn test1() {
+    panic!();
+}
+
+#[test]
+#[should_panic(expected)]
+//~^ WARN: argument must be of the form:
+fn test2() {
+    panic!();
+}
+
+#[test]
+#[should_panic(expect)]
+//~^ WARN: argument must be of the form:
+fn test3() {
+    panic!();
+}
+
+#[test]
+#[should_panic(expected(foo, bar))]
+//~^ WARN: argument must be of the form:
+fn test4() {
+    panic!();
+}
+
+#[test]
+#[should_panic(expected = "foo", bar)]
+//~^ WARN: argument must be of the form:
+fn test5() {
+    panic!();
+}