aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/tests/test.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-22 05:48:55 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-22 05:48:55 +0000
commit2a6544f906818263e2791bc4cdf4fcbdf7260ab9 (patch)
tree12cc178506343e5dbbea0285e1dcd0bd0035398c /crates/ra_syntax/tests/test.rs
parented823cb38d6c6852b2645f6bcd4c3b699b4b7539 (diff)
parentbf8e7930daa3fb168106534b1cc418f5bc44e8c0 (diff)
Merge #1013
1013: Fuzz reparsing and fix found bugs r=matklad a=pcpthm Add fuzz test for reparsing which: - Checks reparsing doesn't panic and validate result syntax tree. - Checks that incremental reparsing produces the same syntax tree as full reparse. - Check for that errors are the same as full reparsing is disabled because errors are less important than syntax tree and produce failures which I couldn't figure out how to fix immediately (FIXME comment). I guess the current input generation is inefficient but still found several bugs: - Arithmetic overflow (negative result on an unsigned type). I changed the signature of `SyntaxError::add_offset` to solve this problem. - When reparsing a leaf, the token of the leaf can be joined to the next characters. Such case was not considered. - UNDERSCORE token was not produced when text length is exactly 1 (not a reparsing bug). - When reparsing a block, *inner* curly braces should be balanced. i.e. `{}{}` is invalid. - Effects of deleting newlines were not considered. Co-authored-by: pcpthm <[email protected]>
Diffstat (limited to 'crates/ra_syntax/tests/test.rs')
-rw-r--r--crates/ra_syntax/tests/test.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_syntax/tests/test.rs b/crates/ra_syntax/tests/test.rs
index 458740c13..537b01368 100644
--- a/crates/ra_syntax/tests/test.rs
+++ b/crates/ra_syntax/tests/test.rs
@@ -8,7 +8,7 @@ use std::{
8}; 8};
9 9
10use test_utils::{project_dir, dir_tests, read_text, collect_tests}; 10use test_utils::{project_dir, dir_tests, read_text, collect_tests};
11use ra_syntax::{SourceFile, AstNode, check_fuzz_invariants}; 11use ra_syntax::{SourceFile, AstNode, fuzz};
12 12
13#[test] 13#[test]
14fn lexer_tests() { 14fn lexer_tests() {
@@ -47,7 +47,16 @@ fn parser_tests() {
47#[test] 47#[test]
48fn parser_fuzz_tests() { 48fn parser_fuzz_tests() {
49 for (_, text) in collect_tests(&test_data_dir(), &["parser/fuzz-failures"]) { 49 for (_, text) in collect_tests(&test_data_dir(), &["parser/fuzz-failures"]) {
50 check_fuzz_invariants(&text) 50 fuzz::check_parser(&text)
51 }
52}
53
54#[test]
55fn reparse_fuzz_tests() {
56 for (_, text) in collect_tests(&test_data_dir(), &["reparse/fuzz-failures"]) {
57 let check = fuzz::CheckReparse::from_data(text.as_bytes()).unwrap();
58 println!("{:?}", check);
59 check.run();
51 } 60 }
52} 61}
53 62