]> git.lizzy.rs Git - rust.git/blob - src/test/ui/panics/panic-handler-set-twice.rs
Rollup merge of #89235 - yaahc:junit-formatting, r=kennytm
[rust.git] / src / test / ui / panics / panic-handler-set-twice.rs
1 // run-pass
2 #![allow(unused_variables)]
3 #![allow(stable_features)]
4
5 #![feature(std_panic)]
6
7 // ignore-emscripten no threads support
8
9 use std::sync::atomic::{AtomicUsize, Ordering};
10 use std::panic;
11 use std::thread;
12
13 static A: AtomicUsize = AtomicUsize::new(0);
14
15 fn main() {
16     panic::set_hook(Box::new(|_| ()));
17     panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
18
19     let _ = thread::spawn(|| {
20         panic!();
21     }).join();
22
23     assert_eq!(1, A.load(Ordering::SeqCst));
24 }