]> git.lizzy.rs Git - rust.git/blob - src/test/ui/panics/panic-handler-flail-wildly.rs
Rollup merge of #89235 - yaahc:junit-formatting, r=kennytm
[rust.git] / src / test / ui / panics / panic-handler-flail-wildly.rs
1 // run-pass
2
3 #![allow(stable_features)]
4 #![allow(unused_must_use)]
5
6 // ignore-emscripten no threads support
7
8 #![feature(std_panic)]
9
10 use std::panic;
11 use std::thread;
12
13 fn a() {
14     panic::set_hook(Box::new(|_| println!("hello yes this is a")));
15     panic::take_hook();
16     panic::set_hook(Box::new(|_| println!("hello yes this is a part 2")));
17     panic::take_hook();
18 }
19
20 fn b() {
21     panic::take_hook();
22     panic::take_hook();
23     panic::take_hook();
24     panic::take_hook();
25     panic::take_hook();
26     panic!();
27 }
28
29 fn c() {
30     panic::set_hook(Box::new(|_| ()));
31     panic::set_hook(Box::new(|_| ()));
32     panic::set_hook(Box::new(|_| ()));
33     panic::set_hook(Box::new(|_| ()));
34     panic::set_hook(Box::new(|_| ()));
35     panic::set_hook(Box::new(|_| ()));
36     panic!();
37 }
38
39 fn main() {
40     for _ in 0..10 {
41         let mut handles = vec![];
42         for _ in 0..10 {
43             handles.push(thread::spawn(a));
44         }
45         for _ in 0..10 {
46             handles.push(thread::spawn(b));
47         }
48         for _ in 0..10 {
49             handles.push(thread::spawn(c));
50         }
51         for handle in handles {
52             let _ = handle.join();
53         }
54     }
55 }