From e0855bccd356d191074a83c2aeedabd88d2b7bab Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Mon, 9 Jun 2014 23:54:52 -0300 Subject: [PATCH] Add a test for nested Arena.alloc --- src/libarena/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 7e0cda26014..ecf595e45d9 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -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() {