tests/catch_panic: make output easier to interpret
This commit is contained in:
parent
0154f6c810
commit
0966799b63
@ -1,5 +1,5 @@
|
||||
// We test the `align_offset` panic below, make sure we test the interpreter impl and not the "real" one.
|
||||
//@compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance
|
||||
//@compile-flags: -Zmiri-symbolic-alignment-check
|
||||
#![feature(never_type)]
|
||||
#![allow(unconditional_panic, non_fmt_panics)]
|
||||
|
||||
@ -48,14 +48,16 @@ fn main() {
|
||||
}));
|
||||
|
||||
// Std panics
|
||||
test(None, |_old_val| std::panic!("Hello from panic: std"));
|
||||
test(None, |old_val| std::panic::panic_any(format!("Hello from panic: {:?}", old_val)));
|
||||
test(None, |old_val| std::panic!("Hello from panic: {:?}", old_val));
|
||||
test(None, |_old_val| std::panic!("Hello from std::panic"));
|
||||
test(None, |old_val| std::panic!("Hello from std::panic: {:?}", old_val));
|
||||
test(None, |old_val| {
|
||||
std::panic::panic_any(format!("Hello from std::panic_any: {:?}", old_val))
|
||||
});
|
||||
test(None, |_old_val| std::panic::panic_any(1337));
|
||||
|
||||
// Core panics
|
||||
test(None, |_old_val| core::panic!("Hello from panic: core"));
|
||||
test(None, |old_val| core::panic!("Hello from panic: {:?}", old_val));
|
||||
test(None, |_old_val| core::panic!("Hello from core::panic"));
|
||||
test(None, |old_val| core::panic!("Hello from core::panic: {:?}", old_val));
|
||||
|
||||
// Built-in panics; also make sure the message is right.
|
||||
test(Some("index out of bounds: the len is 3 but the index is 4"), |_old_val| {
|
||||
@ -68,7 +70,7 @@ fn main() {
|
||||
});
|
||||
|
||||
test(Some("align_offset: align is not a power-of-two"), |_old_val| {
|
||||
let _ = (0usize as *const u8).align_offset(3);
|
||||
let _ = std::ptr::null::<u8>().align_offset(3);
|
||||
loop {}
|
||||
});
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
Hello from panic: std
|
||||
Hello from std::panic
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
Caught panic message (&str): Hello from panic: std
|
||||
Caught panic message (&str): Hello from std::panic
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
Hello from panic: 1
|
||||
Caught panic message (String): Hello from panic: 1
|
||||
Hello from std::panic: 1
|
||||
Caught panic message (String): Hello from std::panic: 1
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
Hello from panic: 2
|
||||
Caught panic message (String): Hello from panic: 2
|
||||
Hello from std::panic_any: 2
|
||||
Caught panic message (String): Hello from std::panic_any: 2
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
Box<dyn Any>
|
||||
Failed to get caught panic message.
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
Hello from panic: core
|
||||
Caught panic message (&str): Hello from panic: core
|
||||
Hello from core::panic
|
||||
Caught panic message (&str): Hello from core::panic
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
Hello from panic: 5
|
||||
Caught panic message (String): Hello from panic: 5
|
||||
Hello from core::panic: 5
|
||||
Caught panic message (String): Hello from core::panic: 5
|
||||
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
|
||||
index out of bounds: the len is 3 but the index is 4
|
||||
Caught panic message (String): index out of bounds: the len is 3 but the index is 4
|
||||
|
Loading…
Reference in New Issue
Block a user