From 64d07c1bd475c4945db8d7cd1fa1a61e467b079b Mon Sep 17 00:00:00 2001 From: darksv Date: Mon, 10 Sep 2018 20:14:09 +0200 Subject: Implement reparsing for remaining blocks --- crates/libsyntax2/tests/test/main.rs | 61 +++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 15 deletions(-) (limited to 'crates/libsyntax2/tests/test/main.rs') diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs index 014faa2c6..24058efa9 100644 --- a/crates/libsyntax2/tests/test/main.rs +++ b/crates/libsyntax2/tests/test/main.rs @@ -23,21 +23,6 @@ fn lexer_tests() { }) } -#[test] -fn parser_tests() { - dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { - let file = File::parse(text); - dump_tree(file.syntax()) - }) -} - -#[test] -fn parser_fuzz_tests() { - for (_, text) in collect_tests(&["parser/fuzz-failures"]) { - check_fuzz_invariants(&text) - } -} - #[test] fn reparse_test() { fn do_check(before: &str, replace_with: &str) { @@ -73,6 +58,52 @@ fn foo { <|>92<|>; } ", "62"); + do_check(r" +mod foo { + fn <|><|> +} +", "bar"); + do_check(r" +trait Foo { + type <|>Foo<|>; +} +", "Output"); + do_check(r" +impl IntoIterator for Foo { + f<|><|> +} +", "n next("); + do_check(r" +use a::b::{foo,<|>,bar<|>}; + ", "baz"); + do_check(r" +pub enum A { + Foo<|><|> +} +", "\nBar;\n"); + do_check(r" +foo!{a, b<|><|> d} +", ", c[3]"); + do_check(r" +extern { + fn<|>;<|> +} +", " exit(code: c_int)"); +} + +#[test] +fn parser_tests() { + dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { + let file = File::parse(text); + dump_tree(file.syntax()) + }) +} + +#[test] +fn parser_fuzz_tests() { + for (_, text) in collect_tests(&["parser/fuzz-failures"]) { + check_fuzz_invariants(&text) + } } -- cgit v1.2.3 From d0cfeb4f1616e125ca3a941f2dcf5dfbb5f2b03f Mon Sep 17 00:00:00 2001 From: darksv Date: Mon, 10 Sep 2018 23:21:16 +0200 Subject: Do not reparse token tree when it is not delimited by braces --- crates/libsyntax2/tests/test/main.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/libsyntax2/tests/test/main.rs') diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs index 24058efa9..644df9f3c 100644 --- a/crates/libsyntax2/tests/test/main.rs +++ b/crates/libsyntax2/tests/test/main.rs @@ -85,6 +85,11 @@ pub enum A { foo!{a, b<|><|> d} ", ", c[3]"); do_check(r" +fn foo() { + vec![<|><|>] +} +", "123"); + do_check(r" extern { fn<|>;<|> } -- cgit v1.2.3