Add a test for nested Arena.alloc
This commit is contained in:
parent
907d961876
commit
e0855bccd3
|
@ -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]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_arena_destructors_fail() {
|
fn test_arena_destructors_fail() {
|
||||||
|
|
Loading…
Reference in New Issue