Add a test for nested Arena.alloc
This commit is contained in:
parent
907d961876
commit
e0855bccd3
1 changed files with 14 additions and 0 deletions
|
@ -298,6 +298,20 @@ fn test_arena_destructors() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_arena_alloc_nested() {
|
||||
struct Inner { value: uint }
|
||||
struct Outer<'a> { inner: &'a Inner }
|
||||
|
||||
let arena = Arena::new();
|
||||
|
||||
let result = arena.alloc(|| Outer {
|
||||
inner: arena.alloc(|| Inner { value: 10 })
|
||||
});
|
||||
|
||||
assert_eq!(result.inner.value, 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_arena_destructors_fail() {
|
||||
|
|
Loading…
Reference in a new issue