Skip to content

Commit a51cd61

Browse files
committed
Add a test
1 parent 2e8e8ab commit a51cd61

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/libstd/io/stdio.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,29 @@ pub fn _print(args: fmt::Arguments) {
402402
panic!("failed printing to stdout: {}", e);
403403
}
404404
}
405+
406+
#[cfg(test)]
407+
mod test {
408+
use thread;
409+
use super::*;
410+
411+
#[test]
412+
fn panic_doesnt_poison() {
413+
thread::spawn(|| {
414+
let _a = stdin();
415+
let _a = _a.lock();
416+
let _a = stdout();
417+
let _a = _a.lock();
418+
let _a = stderr();
419+
let _a = _a.lock();
420+
panic!();
421+
}).join().unwrap_err();
422+
423+
let _a = stdin();
424+
let _a = _a.lock();
425+
let _a = stdout();
426+
let _a = _a.lock();
427+
let _a = stderr();
428+
let _a = _a.lock();
429+
}
430+
}

0 commit comments

Comments
 (0)