]> git.lizzy.rs Git - rust.git/commitdiff
Add a test for nested Arena.alloc
authorRenato Zannon <renato@rrsz.com.br>
Tue, 10 Jun 2014 02:54:52 +0000 (23:54 -0300)
committerRenato Zannon <renato@rrsz.com.br>
Tue, 10 Jun 2014 02:54:52 +0000 (23:54 -0300)
src/libarena/lib.rs

index 7e0cda26014a5298d8293e6180aba590245d02a1..ecf595e45d99509af358d0023793ec91cad0783b 100644 (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() {