From d864edc349f2548d9b05c7fa99f1387946e18f8b Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 23 Aug 2018 16:49:00 +0200 Subject: [PATCH] improve the run-pass test --- .../run-pass/panic-uninitialized-zeroed.rs | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/test/run-pass/panic-uninitialized-zeroed.rs b/src/test/run-pass/panic-uninitialized-zeroed.rs index a4115f8fa1d..fd88bba49c4 100644 --- a/src/test/run-pass/panic-uninitialized-zeroed.rs +++ b/src/test/run-pass/panic-uninitialized-zeroed.rs @@ -22,10 +22,40 @@ struct Foo { fn main() { unsafe { - panic::catch_unwind(|| mem::uninitialized::()).is_err(); - panic::catch_unwind(|| mem::zeroed::()).is_err(); + assert_eq!( + panic::catch_unwind(|| { + mem::uninitialized::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type ! using mem::uninitialized" + })), + Some(true) + ); - panic::catch_unwind(|| mem::uninitialized::()).is_err(); - panic::catch_unwind(|| mem::zeroed::()).is_err(); + assert_eq!( + panic::catch_unwind(|| { + mem::zeroed::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type ! using mem::zeroed" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::uninitialized::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Foo using mem::uninitialized" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::zeroed::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Foo using mem::zeroed" + })), + Some(true) + ); } }