]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
a2a8927a | 2 | // needs-unwind |
7453a54e SL |
3 | // ignore-emscripten no threads support |
4 | ||
9fa01778 | 5 | use std::sync::atomic::{AtomicUsize, Ordering}; |
9cc50fc6 SL |
6 | use std::panic; |
7 | use std::thread; | |
8 | ||
9fa01778 | 9 | static A: AtomicUsize = AtomicUsize::new(0); |
9cc50fc6 SL |
10 | |
11 | fn main() { | |
3157f602 | 12 | panic::set_hook(Box::new(|_| { |
9cc50fc6 | 13 | A.fetch_add(1, Ordering::SeqCst); |
3157f602 | 14 | })); |
9cc50fc6 SL |
15 | |
16 | let result = thread::spawn(|| { | |
3157f602 | 17 | let result = panic::catch_unwind(|| { |
9cc50fc6 SL |
18 | panic!("hi there"); |
19 | }); | |
20 | ||
3157f602 | 21 | panic::resume_unwind(result.unwrap_err()); |
9cc50fc6 SL |
22 | }).join(); |
23 | ||
a7813a04 | 24 | let msg = *result.unwrap_err().downcast::<&'static str>().unwrap(); |
9cc50fc6 SL |
25 | assert_eq!("hi there", msg); |
26 | assert_eq!(1, A.load(Ordering::SeqCst)); | |
27 | } |