improve the run-pass test

This commit is contained in:
Jorge Aparicio 2018-08-23 16:49:00 +02:00
parent bc5b567a32
commit d864edc349

View File

@ -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::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type ! using mem::uninitialized"
})),
Some(true)
);
panic::catch_unwind(|| mem::uninitialized::<Foo>()).is_err();
panic::catch_unwind(|| mem::zeroed::<Foo>()).is_err();
assert_eq!(
panic::catch_unwind(|| {
mem::zeroed::<!>()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type ! using mem::zeroed"
})),
Some(true)
);
assert_eq!(
panic::catch_unwind(|| {
mem::uninitialized::<Foo>()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type Foo using mem::uninitialized"
})),
Some(true)
);
assert_eq!(
panic::catch_unwind(|| {
mem::zeroed::<Foo>()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type Foo using mem::zeroed"
})),
Some(true)
);
}
}