diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-22 14:40:56 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-22 14:40:56 +0100 |
| commit | 2ce727fc958d9b83f7d2f46f73e4f295594b48a6 (patch) | |
| tree | 1f4fc5be25b61a8a633311ff7ec892cacdffe288 /tests/src/tests.rs | |
| parent | dd9c323941260a1d08d5113dbefa023713f553da (diff) | |
Make inner node and node data private
Diffstat (limited to 'tests/src/tests.rs')
| -rw-r--r-- | tests/src/tests.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/src/tests.rs b/tests/src/tests.rs index a867f065..52cc54db 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -606,7 +606,7 @@ fn test_reparse(text: &str, i: usize, rng: &mut LinearShift) -> bool { } let source = Source::detached(text); - let leafs = source.root().leafs(); + let leafs = leafs(source.root()); let start = source.range(leafs[pick(0..leafs.len())].span()).start; let supplement = supplements[pick(0..supplements.len())]; ok &= apply(start..start, supplement); @@ -614,6 +614,15 @@ fn test_reparse(text: &str, i: usize, rng: &mut LinearShift) -> bool { ok } +/// Returns all leaf descendants of a node (may include itself). +fn leafs(node: &SyntaxNode) -> Vec<SyntaxNode> { + if node.children().len() == 0 { + vec![node.clone()] + } else { + node.children().flat_map(leafs).collect() + } +} + /// Ensure that all spans are properly ordered (and therefore unique). #[track_caller] fn test_spans(root: &SyntaxNode) -> bool { |
