diff --git a/servo/src/util/tree.rs b/servo/src/util/tree.rs index fb3acd21fd09..2dba99ed6999 100644 --- a/servo/src/util/tree.rs +++ b/servo/src/util/tree.rs @@ -77,8 +77,7 @@ mod test { dummy(@{fields: empty(), value: v}) } - #[test] - fn add_child_0() { + fn parent_with_3_children() -> {p: dummy, children: [dummy]} { let children = [new_dummy(0u), new_dummy(1u), new_dummy(2u)]; @@ -88,6 +87,12 @@ mod test { add_child(p, c); } + ret {p: p, children: children}; + } + + #[test] + fn add_child_0() { + let {p, children} = parent_with_3_children(); let mut i = 0u; for each_child(p) {|c| assert c.value == i; @@ -95,4 +100,15 @@ mod test { } assert i == children.len(); } + + #[test] + fn add_child_break() { + let {p, _} = parent_with_3_children(); + let mut i = 0u; + for each_child(p) {|_c| + i += 1u; + break; + } + assert i == 1u; + } } \ No newline at end of file