rust/tests/ui/panics/panic-handler-set-twice.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
518 B
Rust
Raw Normal View History

// run-pass
// needs-unwind
#![allow(unused_variables)]
#![allow(stable_features)]
2018-07-22 21:14:42 -05:00
#![feature(std_panic)]
2015-12-18 01:51:55 -06:00
// ignore-emscripten no threads support
2015-12-18 01:51:55 -06:00
use std::sync::atomic::{AtomicUsize, Ordering};
use std::panic;
use std::thread;
static A: AtomicUsize = AtomicUsize::new(0);
fn main() {
2016-03-15 22:38:58 -05:00
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
2015-12-18 01:51:55 -06:00
let _ = thread::spawn(|| {
panic!();
}).join();
assert_eq!(1, A.load(Ordering::SeqCst));
}