summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-22 14:40:56 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-22 14:40:56 +0100
commit2ce727fc958d9b83f7d2f46f73e4f295594b48a6 (patch)
tree1f4fc5be25b61a8a633311ff7ec892cacdffe288 /tests/src
parentdd9c323941260a1d08d5113dbefa023713f553da (diff)
Make inner node and node data private
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/tests.rs11
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 {