Skip to content

Commit

Permalink
Update rpass tests for panic hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Mar 16, 2016
1 parent 157e1bc commit 50fda1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/test/run-pass/panic-handler-chain.rs
Expand Up @@ -17,12 +17,12 @@ static A: AtomicUsize = AtomicUsize::new(0);
static B: AtomicUsize = AtomicUsize::new(0);

fn main() {
panic::set_handler(|_| { A.fetch_add(1, Ordering::SeqCst); });
let handler = panic::take_handler();
panic::set_handler(move |info| {
panic::set_hook(Box::new(|_| { A.fetch_add(1, Ordering::SeqCst); }));
let hook = panic::take_hook();
panic::set_hook(Box::new(move |info| {
B.fetch_add(1, Ordering::SeqCst);
handler(info);
});
hook(info);
}));

let _ = thread::spawn(|| {
panic!();
Expand Down
30 changes: 15 additions & 15 deletions src/test/run-pass/panic-handler-flail-wildly.rs
Expand Up @@ -15,28 +15,28 @@ use std::panic;
use std::thread;

fn a() {
panic::set_handler(|_| println!("hello yes this is a"));
panic::take_handler();
panic::set_handler(|_| println!("hello yes this is a part 2"));
panic::take_handler();
panic::set_hook(Box::new(|_| println!("hello yes this is a")));
panic::take_hook();
panic::set_hook(Box::new(|_| println!("hello yes this is a part 2")));
panic::take_hook();
}

fn b() {
panic::take_handler();
panic::take_handler();
panic::take_handler();
panic::take_handler();
panic::take_handler();
panic::take_hook();
panic::take_hook();
panic::take_hook();
panic::take_hook();
panic::take_hook();
panic!();
}

fn c() {
panic::set_handler(|_| ());
panic::set_handler(|_| ());
panic::set_handler(|_| ());
panic::set_handler(|_| ());
panic::set_handler(|_| ());
panic::set_handler(|_| ());
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|_| ()));
panic!();
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/panic-handler-set-twice.rs
Expand Up @@ -18,8 +18,8 @@ use std::thread;
static A: AtomicUsize = AtomicUsize::new(0);

fn main() {
panic::set_handler(|_| ());
panic::set_handler(|info| { A.fetch_add(1, Ordering::SeqCst); });
panic::set_hook(Box::new(|_| ()));
panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); }));

let _ = thread::spawn(|| {
panic!();
Expand Down

0 comments on commit 50fda1e

Please sign in to comment.