Skip to content

Commit ac61ce7

Browse files
committed
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.
1 parent 9db64d5 commit ac61ce7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,22 @@ fn test_drop_panics() {
127127
}
128128
}
129129
}
130+
// check if rust is new enough
131+
flag.set(0);
132+
{
133+
let array = vec![Bump(flag), Bump(flag)];
134+
let res = catch_unwind(AssertUnwindSafe(|| {
135+
drop(array);
136+
}));
137+
assert!(res.is_err());
138+
}
130139

140+
if flag.get() != 2 {
141+
println!("test_drop_panics: skip, this version of Rust doesn't continue in drop_in_place");
142+
return;
143+
}
144+
145+
flag.set(0);
131146
{
132147
let mut array = ArrayVec::<[Bump; 128]>::new();
133148
array.push(Bump(flag));

0 commit comments

Comments
 (0)