about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2015-03-18 09:03:17 -0700
committerSteven Fackler <sfackler@gmail.com>2015-03-18 09:03:17 -0700
commita51cd6116446d74a336abcb00f5ced3582ec307f (patch)
treefabe87bed01a6cf16b0c0b34b102a8b4cc33afc4 /src/libstd
parent2e8e8ab564891c3d2ffeeb0f8e1a4e850866f74f (diff)
downloadrust-a51cd6116446d74a336abcb00f5ced3582ec307f.tar.gz
rust-a51cd6116446d74a336abcb00f5ced3582ec307f.zip
Add a test
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/stdio.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 615607eed1b..9b36408aa51 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -402,3 +402,29 @@ pub fn _print(args: fmt::Arguments) {
         panic!("failed printing to stdout: {}", e);
     }
 }
+
+#[cfg(test)]
+mod test {
+    use thread;
+    use super::*;
+
+    #[test]
+    fn panic_doesnt_poison() {
+        thread::spawn(|| {
+            let _a = stdin();
+            let _a = _a.lock();
+            let _a = stdout();
+            let _a = _a.lock();
+            let _a = stderr();
+            let _a = _a.lock();
+            panic!();
+        }).join().unwrap_err();
+
+        let _a = stdin();
+        let _a = _a.lock();
+        let _a = stdout();
+        let _a = _a.lock();
+        let _a = stderr();
+        let _a = _a.lock();
+    }
+}