Skip to content

Commit e0855bc

Browse files
committed
Add a test for nested Arena.alloc
1 parent 907d961 commit e0855bc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libarena/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,20 @@ fn test_arena_destructors() {
298298
}
299299
}
300300

301+
#[test]
302+
fn test_arena_alloc_nested() {
303+
struct Inner { value: uint }
304+
struct Outer<'a> { inner: &'a Inner }
305+
306+
let arena = Arena::new();
307+
308+
let result = arena.alloc(|| Outer {
309+
inner: arena.alloc(|| Inner { value: 10 })
310+
});
311+
312+
assert_eq!(result.inner.value, 10);
313+
}
314+
301315
#[test]
302316
#[should_fail]
303317
fn test_arena_destructors_fail() {

0 commit comments

Comments
 (0)