Add a test for nested Arena.alloc

This commit is contained in:
Renato Zannon 2014-06-09 23:54:52 -03:00
parent 907d961876
commit e0855bccd3

View File

@ -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() {