about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-24 08:55:41 -0800
committerManish Goregaokar <manishsmail@gmail.com>2018-02-24 12:47:58 -0800
commitb52b33a38626306ec2f622f101e7edc2964abfe4 (patch)
tree4b27672436eb209ea15241c131367efa67881eb1 /src/test
parenta79e5e210e5e20077b2a5cf6c0c8d2bdc11e6066 (diff)
parent10f7c110928ee7d3db7fef15fd7dce776b17e161 (diff)
downloadrust-b52b33a38626306ec2f622f101e7edc2964abfe4.tar.gz
rust-b52b33a38626306ec2f622f101e7edc2964abfe4.zip
Rollup merge of #48143 - nikomatsakis:termination_trait_in_tests, r=eddyb
Termination trait in tests

Support the `Termination` trait in unit tests (cc https://github.com/rust-lang/rust/issues/43301)

Also, a drive-by fix for #47075.

This is joint work with @bkchr.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-12997-2.rs3
-rw-r--r--src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs2
-rw-r--r--src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs2
-rw-r--r--src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs (renamed from src/test/run-pass/termination-trait-for-result-box-error_ok.rs)8
-rw-r--r--src/test/run-pass/rfc-1937-termination-trait/termination-trait-in-test.rs43
-rw-r--r--src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs21
6 files changed, 70 insertions, 9 deletions
diff --git a/src/test/compile-fail/issue-12997-2.rs b/src/test/compile-fail/issue-12997-2.rs
index 85d91bb2db2..8d3df68577b 100644
--- a/src/test/compile-fail/issue-12997-2.rs
+++ b/src/test/compile-fail/issue-12997-2.rs
@@ -15,6 +15,3 @@
 #[bench]
 fn bar(x: isize) { }
 //~^ ERROR mismatched types
-//~| expected type `for<'r> fn(&'r mut __test::test::Bencher)`
-//~| found type `fn(isize) {bar}`
-//~| expected mutable reference, found isize
diff --git a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs b/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs
index a63162cf73d..93e2561adf7 100644
--- a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs
+++ b/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs
@@ -10,6 +10,6 @@
 #![feature(termination_trait)]
 
 fn main() -> char {
-//~^ ERROR: the trait bound `char: std::Termination` is not satisfied
+//~^ ERROR: the trait bound `char: std::process::Termination` is not satisfied
     ' '
 }
diff --git a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs b/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs
index 788c38c55be..e87e0ceebf1 100644
--- a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs
+++ b/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs
@@ -12,6 +12,6 @@
 
 struct ReturnType {}
 
-fn main() -> ReturnType { //~ ERROR `ReturnType: std::Termination` is not satisfied
+fn main() -> ReturnType { //~ ERROR `ReturnType: std::process::Termination` is not satisfied
     ReturnType {}
 }
diff --git a/src/test/run-pass/termination-trait-for-result-box-error_ok.rs b/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs
index 269ac451cf4..c1dd44a9176 100644
--- a/src/test/run-pass/termination-trait-for-result-box-error_ok.rs
+++ b/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs
@@ -1,4 +1,4 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -10,8 +10,8 @@
 
 #![feature(termination_trait)]
 
-use std::io::Error;
+// error-pattern:oh, dear
 
-fn main() -> Result<(), Box<Error>> {
-    Ok(())
+fn main() -> ! {
+    panic!("oh, dear");
 }
diff --git a/src/test/run-pass/rfc-1937-termination-trait/termination-trait-in-test.rs b/src/test/run-pass/rfc-1937-termination-trait/termination-trait-in-test.rs
new file mode 100644
index 00000000000..494500d522a
--- /dev/null
+++ b/src/test/run-pass/rfc-1937-termination-trait/termination-trait-in-test.rs
@@ -0,0 +1,43 @@
+// Copyright 2017 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
+
+#![feature(termination_trait)]
+#![feature(test)]
+
+extern crate test;
+use std::num::ParseIntError;
+use test::Bencher;
+
+#[test]
+fn is_a_num() -> Result<(), ParseIntError> {
+    let _: u32 = "22".parse()?;
+    Ok(())
+}
+
+#[test]
+#[should_panic]
+fn not_a_num() -> Result<(), ParseIntError> {
+    let _: u32 = "abc".parse()?;
+    Ok(())
+}
+
+#[bench]
+fn test_a_positive_bench(_: &mut Bencher) -> Result<(), ParseIntError> {
+    Ok(())
+}
+
+#[bench]
+#[should_panic]
+fn test_a_neg_bench(_: &mut Bencher) -> Result<(), ParseIntError> {
+    let _: u32 = "abc".parse()?;
+    Ok(())
+}
diff --git a/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs b/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs
new file mode 100644
index 00000000000..796f652d6b5
--- /dev/null
+++ b/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs
@@ -0,0 +1,21 @@
+// Copyright 2017 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.
+
+// Check that `#[test]` works with extern-absolute-paths enabled.
+//
+// Regression test for #47075.
+
+// compile-flags: --test
+
+#![feature(extern_absolute_paths)]
+
+#[test]
+fn test() {
+}