aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorpcpthm <[email protected]>2019-03-21 17:05:12 +0000
committerpcpthm <[email protected]>2019-03-21 23:04:48 +0000
commite734190c24d2a5aca5b62c2b1ab7e6136017a25c (patch)
tree106ca91f918767cdee896d879ece4930410b6ea7 /crates/ra_syntax/src
parent51323a852a8979a71c21725b3b2771224132b85f (diff)
Refactor parser fuzz testing
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/fuzz.rs12
-rw-r--r--crates/ra_syntax/src/lib.rs9
2 files changed, 14 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs
new file mode 100644
index 000000000..03f453a6e
--- /dev/null
+++ b/crates/ra_syntax/src/fuzz.rs
@@ -0,0 +1,12 @@
1use crate::{SourceFile, validation, AstNode};
2
3fn check_file_invariants(file: &SourceFile) {
4 let root = file.syntax();
5 validation::validate_block_structure(root);
6 let _ = file.errors();
7}
8
9pub fn check_parser(text: &str) {
10 let file = SourceFile::parse(text);
11 check_file_invariants(&file);
12}
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 7334d53ef..4f3020440 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -29,6 +29,8 @@ mod ptr;
29 29
30pub mod algo; 30pub mod algo;
31pub mod ast; 31pub mod ast;
32#[doc(hidden)]
33pub mod fuzz;
32 34
33pub use rowan::{SmolStr, TextRange, TextUnit}; 35pub use rowan::{SmolStr, TextRange, TextUnit};
34pub use ra_parser::SyntaxKind; 36pub use ra_parser::SyntaxKind;
@@ -83,13 +85,6 @@ impl SourceFile {
83 } 85 }
84} 86}
85 87
86pub fn check_fuzz_invariants(text: &str) {
87 let file = SourceFile::parse(text);
88 let root = file.syntax();
89 validation::validate_block_structure(root);
90 let _ = file.errors();
91}
92
93/// This test does not assert anything and instead just shows off the crate's 88/// This test does not assert anything and instead just shows off the crate's
94/// API. 89/// API.
95#[test] 90#[test]