From ac61ce748b3f1509f7e09b1021ac7dbb431f4259 Mon Sep 17 00:00:00 2001 From: bluss Date: Sun, 25 Mar 2018 23:49:42 +0200 Subject: [PATCH] TEST: Fix drop tests for older Rust In the test, test with Vec first to see how Rust implements panic recovery while elements drop. If Vec drops all the elements, then we test that arrayvec does too. --- tests/tests.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/tests.rs b/tests/tests.rs index 7e3c4c7..5b0f3aa 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -127,7 +127,22 @@ fn test_drop_panics() { } } } + // check if rust is new enough + flag.set(0); + { + let array = vec![Bump(flag), Bump(flag)]; + let res = catch_unwind(AssertUnwindSafe(|| { + drop(array); + })); + assert!(res.is_err()); + } + if flag.get() != 2 { + println!("test_drop_panics: skip, this version of Rust doesn't continue in drop_in_place"); + return; + } + + flag.set(0); { let mut array = ArrayVec::<[Bump; 128]>::new(); array.push(Bump(flag));