aboutsummaryrefslogtreecommitdiff
path: root/tests/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parser.rs')
-rw-r--r--tests/parser.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/parser.rs b/tests/parser.rs
index 206da2a64..43d04e491 100644
--- a/tests/parser.rs
+++ b/tests/parser.rs
@@ -7,7 +7,7 @@ use std::path::{PathBuf, Path};
7use std::fs::read_dir; 7use std::fs::read_dir;
8use std::fmt::Write; 8use std::fmt::Write;
9 9
10use libsyntax2::{tokenize, parse, Token, Node, File, FileBuilder}; 10use libsyntax2::{tokenize, parse, Node, File};
11 11
12#[test] 12#[test]
13fn parser_tests() { 13fn parser_tests() {
@@ -70,14 +70,24 @@ fn dump_tree(file: &File) -> String {
70 70
71 fn go(node: Node, buff: &mut String, level: usize) { 71 fn go(node: Node, buff: &mut String, level: usize) {
72 buff.push_str(&String::from(" ").repeat(level)); 72 buff.push_str(&String::from(" ").repeat(level));
73 write!(buff, "{:?}", node).unwrap(); 73 write!(buff, "{:?}\n", node).unwrap();
74 for err in node.errors() { 74 let my_errors = node.errors().filter(|e| e.after_child().is_none());
75 write!(buff, " err: `{}`", err.message()).unwrap(); 75 let parent_errors = node.parent().into_iter()
76 .flat_map(|n| n.errors())
77 .filter(|e| e.after_child() == Some(node));
78
79 for err in my_errors {
80 buff.push_str(&String::from(" ").repeat(level));
81 write!(buff, "err: `{}`\n", err.message()).unwrap();
76 } 82 }
77 write!(buff, "\n").unwrap();
78 83
79 for child in node.children() { 84 for child in node.children() {
80 go(child, buff, level + 1) 85 go(child, buff, level + 1)
81 } 86 }
87
88 for err in parent_errors {
89 buff.push_str(&String::from(" ").repeat(level));
90 write!(buff, "err: `{}`\n", err.message()).unwrap();
91 }
82 } 92 }
83} 93}