Skip to content

Commit

Permalink
Add a test for nested Arena.alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
renato-zannon committed Jun 10, 2014
1 parent 907d961 commit e0855bc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libarena/lib.rs
Expand Up @@ -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() {
Expand Down

0 comments on commit e0855bc

Please sign in to comment.