aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/fuzz.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-29 07:40:39 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-29 07:40:39 +0100
commit7a1cae59acf72f821343b2ba10ef69fb92a5b952 (patch)
tree26e606ccd132a24e9bc89cf174e4adadf60c5992 /crates/ra_syntax/src/fuzz.rs
parentb0d84cb8faefedde7ace4ff152a2a13408e79e5d (diff)
parent80a17251473bd6213a4c8a51ea7f732394d173c5 (diff)
Merge #1337
1337: Move syntax errors our of syntax tree r=matklad a=matklad I am not really sure if it's a good idea, but `SyntaxError` do not really belong to a `SyntaxTree`. So let's just store them on the side? Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/fuzz.rs')
-rw-r--r--crates/ra_syntax/src/fuzz.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs
index af11b2e1a..6a9905bd1 100644
--- a/crates/ra_syntax/src/fuzz.rs
+++ b/crates/ra_syntax/src/fuzz.rs
@@ -5,12 +5,11 @@ use std::str::{self, FromStr};
5fn check_file_invariants(file: &SourceFile) { 5fn check_file_invariants(file: &SourceFile) {
6 let root = file.syntax(); 6 let root = file.syntax();
7 validation::validate_block_structure(root); 7 validation::validate_block_structure(root);
8 let _ = file.errors();
9} 8}
10 9
11pub fn check_parser(text: &str) { 10pub fn check_parser(text: &str) {
12 let file = SourceFile::parse(text); 11 let file = SourceFile::parse(text);
13 check_file_invariants(&file); 12 check_file_invariants(&file.tree);
14} 13}
15 14
16#[derive(Debug, Clone)] 15#[derive(Debug, Clone)]
@@ -44,16 +43,18 @@ impl CheckReparse {
44 } 43 }
45 44
46 pub fn run(&self) { 45 pub fn run(&self) {
47 let file = SourceFile::parse(&self.text); 46 let parse = SourceFile::parse(&self.text);
48 let new_file = file.reparse(&self.edit); 47 let new_parse = parse.reparse(&self.edit);
49 check_file_invariants(&new_file); 48 check_file_invariants(&new_parse.tree);
50 assert_eq!(&new_file.syntax().text().to_string(), &self.edited_text); 49 assert_eq!(&new_parse.tree.syntax().text().to_string(), &self.edited_text);
51 let full_reparse = SourceFile::parse(&self.edited_text); 50 let full_reparse = SourceFile::parse(&self.edited_text);
52 for (a, b) in new_file.syntax().descendants().zip(full_reparse.syntax().descendants()) { 51 for (a, b) in
52 new_parse.tree.syntax().descendants().zip(full_reparse.tree.syntax().descendants())
53 {
53 if (a.kind(), a.range()) != (b.kind(), b.range()) { 54 if (a.kind(), a.range()) != (b.kind(), b.range()) {
54 eprint!("original:\n{}", file.syntax().debug_dump()); 55 eprint!("original:\n{}", parse.tree.syntax().debug_dump());
55 eprint!("reparsed:\n{}", new_file.syntax().debug_dump()); 56 eprint!("reparsed:\n{}", new_parse.tree.syntax().debug_dump());
56 eprint!("full reparse:\n{}", full_reparse.syntax().debug_dump()); 57 eprint!("full reparse:\n{}", full_reparse.tree.syntax().debug_dump());
57 assert_eq!( 58 assert_eq!(
58 format!("{:?}", a), 59 format!("{:?}", a),
59 format!("{:?}", b), 60 format!("{:?}", b),