From a51cd6116446d74a336abcb00f5ced3582ec307f Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 18 Mar 2015 09:03:17 -0700 Subject: [PATCH] Add a test --- src/libstd/io/stdio.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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(); + } +}