aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/tests')
-rw-r--r--crates/libsyntax2/tests/test/main.rs76
1 files changed, 1 insertions, 75 deletions
diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs
index 644df9f3c..5a8879fce 100644
--- a/crates/libsyntax2/tests/test/main.rs
+++ b/crates/libsyntax2/tests/test/main.rs
@@ -9,9 +9,8 @@ use std::{
9 fmt::Write, 9 fmt::Write,
10}; 10};
11 11
12use test_utils::extract_range;
13use libsyntax2::{ 12use libsyntax2::{
14 File, AtomEdit, 13 File,
15 utils::{dump_tree, check_fuzz_invariants}, 14 utils::{dump_tree, check_fuzz_invariants},
16}; 15};
17 16
@@ -24,79 +23,6 @@ fn lexer_tests() {
24} 23}
25 24
26#[test] 25#[test]
27fn reparse_test() {
28 fn do_check(before: &str, replace_with: &str) {
29 let (range, before) = extract_range(before);
30 let after = libsyntax2::replace_range(before.clone(), range, replace_with);
31
32 let fully_reparsed = File::parse(&after);
33 let incrementally_reparsed = {
34 let f = File::parse(&before);
35 let edit = AtomEdit { delete: range, insert: replace_with.to_string() };
36 f.incremental_reparse(&edit).unwrap()
37 };
38 assert_eq_text!(
39 &dump_tree(fully_reparsed.syntax()),
40 &dump_tree(incrementally_reparsed.syntax()),
41 )
42 }
43
44 do_check(r"
45fn foo() {
46 let x = foo + <|>bar<|>
47}
48", "baz");
49 do_check(r"
50struct Foo {
51 f: foo<|><|>
52}
53", ",\n g: (),");
54 do_check(r"
55fn foo {
56 let;
57 1 + 1;
58 <|>92<|>;
59}
60", "62");
61 do_check(r"
62mod foo {
63 fn <|><|>
64}
65", "bar");
66 do_check(r"
67trait Foo {
68 type <|>Foo<|>;
69}
70", "Output");
71 do_check(r"
72impl IntoIterator<Item=i32> for Foo {
73 f<|><|>
74}
75", "n next(");
76 do_check(r"
77use a::b::{foo,<|>,bar<|>};
78 ", "baz");
79 do_check(r"
80pub enum A {
81 Foo<|><|>
82}
83", "\nBar;\n");
84 do_check(r"
85foo!{a, b<|><|> d}
86", ", c[3]");
87 do_check(r"
88fn foo() {
89 vec![<|><|>]
90}
91", "123");
92 do_check(r"
93extern {
94 fn<|>;<|>
95}
96", " exit(code: c_int)");
97}
98
99#[test]
100fn parser_tests() { 26fn parser_tests() {
101 dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { 27 dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| {
102 let file = File::parse(text); 28 let file = File::parse(text);