2025-04-08 09:40:37 +08:00
|
|
|
//@ compile-flags: --test
|
|
|
|
//@ run-flags: --test-threads=1 --nocapture
|
2025-03-17 22:22:32 +08:00
|
|
|
//@ run-fail
|
|
|
|
//@ check-run-results
|
|
|
|
//@ exec-env:RUST_BACKTRACE=0
|
|
|
|
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
2025-04-08 09:40:37 +08:00
|
|
|
//@ normalize-stdout: "TypeId\(0x[0-9a-f]+\)" -> "TypeId($$HEX)"
|
|
|
|
//@ needs-threads
|
|
|
|
//@ needs-unwind (panic)
|
2025-03-17 22:22:32 +08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic]
|
|
|
|
fn should_panic_with_any_message() {
|
|
|
|
panic!("Panic!");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic = "message"]
|
|
|
|
fn should_panic_with_message() {
|
|
|
|
panic!("message");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic]
|
|
|
|
fn should_panic_with_any_message_does_not_panic() {
|
|
|
|
// DON'T PANIC
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic = "message"]
|
|
|
|
fn should_panic_with_message_does_not_panic() {
|
|
|
|
// DON'T PANIC
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic = "message"]
|
|
|
|
fn should_panic_with_substring_panics_with_incorrect_string() {
|
|
|
|
panic!("ZOMGWTFBBQ");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic = "message"]
|
2025-04-08 09:40:37 +08:00
|
|
|
#[expect(non_fmt_panics)]
|
2025-03-17 22:22:32 +08:00
|
|
|
fn should_panic_with_substring_panics_with_non_string_value() {
|
2025-04-08 09:40:37 +08:00
|
|
|
panic!(123);
|
2025-03-17 22:22:32 +08:00
|
|
|
}
|