mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Refactor parser fuzz testing
This commit is contained in:
parent
51323a852a
commit
e734190c24
5 changed files with 23 additions and 16 deletions
12
crates/ra_syntax/src/fuzz.rs
Normal file
12
crates/ra_syntax/src/fuzz.rs
Normal file
|
@ -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);
|
||||
}
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue