diff options
author | pcpthm <[email protected]> | 2019-03-21 17:05:12 +0000 |
---|---|---|
committer | pcpthm <[email protected]> | 2019-03-21 23:04:48 +0000 |
commit | e734190c24d2a5aca5b62c2b1ab7e6136017a25c (patch) | |
tree | 106ca91f918767cdee896d879ece4930410b6ea7 /crates/ra_syntax/src | |
parent | 51323a852a8979a71c21725b3b2771224132b85f (diff) |
Refactor parser fuzz testing
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/fuzz.rs | 12 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 9 |
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 @@ | |||
1 | use crate::{SourceFile, validation, AstNode}; | ||
2 | |||
3 | fn check_file_invariants(file: &SourceFile) { | ||
4 | let root = file.syntax(); | ||
5 | validation::validate_block_structure(root); | ||
6 | let _ = file.errors(); | ||
7 | } | ||
8 | |||
9 | pub 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 | ||
30 | pub mod algo; | 30 | pub mod algo; |
31 | pub mod ast; | 31 | pub mod ast; |
32 | #[doc(hidden)] | ||
33 | pub mod fuzz; | ||
32 | 34 | ||
33 | pub use rowan::{SmolStr, TextRange, TextUnit}; | 35 | pub use rowan::{SmolStr, TextRange, TextUnit}; |
34 | pub use ra_parser::SyntaxKind; | 36 | pub use ra_parser::SyntaxKind; |
@@ -83,13 +85,6 @@ impl SourceFile { | |||
83 | } | 85 | } |
84 | } | 86 | } |
85 | 87 | ||
86 | pub 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] |