From e734190c24d2a5aca5b62c2b1ab7e6136017a25c Mon Sep 17 00:00:00 2001 From: pcpthm Date: Fri, 22 Mar 2019 02:05:12 +0900 Subject: Refactor parser fuzz testing --- crates/ra_syntax/src/fuzz.rs | 12 ++++++++++++ crates/ra_syntax/src/lib.rs | 9 ++------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 crates/ra_syntax/src/fuzz.rs (limited to 'crates/ra_syntax/src') 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 @@ +use crate::{SourceFile, validation, AstNode}; + +fn check_file_invariants(file: &SourceFile) { + let root = file.syntax(); + validation::validate_block_structure(root); + let _ = file.errors(); +} + +pub fn check_parser(text: &str) { + let file = SourceFile::parse(text); + check_file_invariants(&file); +} 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; pub mod algo; pub mod ast; +#[doc(hidden)] +pub mod fuzz; pub use rowan::{SmolStr, TextRange, TextUnit}; pub use ra_parser::SyntaxKind; @@ -83,13 +85,6 @@ impl SourceFile { } } -pub fn check_fuzz_invariants(text: &str) { - let file = SourceFile::parse(text); - let root = file.syntax(); - validation::validate_block_structure(root); - let _ = file.errors(); -} - /// This test does not assert anything and instead just shows off the crate's /// API. #[test] -- cgit v1.2.3