summaryrefslogtreecommitdiffstats
path: root/src/test/ui/panics/panic-handler-set-twice.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/panics/panic-handler-set-twice.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/panics/panic-handler-set-twice.rs b/src/test/ui/panics/panic-handler-set-twice.rs
new file mode 100644
index 000000000..274453020
--- /dev/null
+++ b/src/test/ui/panics/panic-handler-set-twice.rs
@@ -0,0 +1,25 @@
+// run-pass
+// needs-unwind
+#![allow(unused_variables)]
+#![allow(stable_features)]
+
+#![feature(std_panic)]
+
+// ignore-emscripten no threads support
+
+use std::sync::atomic::{AtomicUsize, Ordering};
+use std::panic;
+use std::thread;
+
+static A: AtomicUsize = AtomicUsize::new(0);
+
+fn main() {
+ panic::set_hook(Box::new(|_| ()));
+ panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));
+
+ let _ = thread::spawn(|| {
+ panic!();
+ }).join();
+
+ assert_eq!(1, A.load(Ordering::SeqCst));
+}