diff options
author | darksv <[email protected]> | 2018-09-13 22:25:05 +0100 |
---|---|---|
committer | darksv <[email protected]> | 2018-09-13 22:25:05 +0100 |
commit | 4356240fa42eebbd17fdb63b2d0e6f86387ca21c (patch) | |
tree | 96785c930199eac49a9f48cd1d9c67f0f7c1dc4f /crates/libsyntax2/tests/test/main.rs | |
parent | b6f8037a6f8fbcb4f127e1d2b518279650b1f5ea (diff) |
Incremental reparsing for single tokens (WHITESPACE, COMMENT, DOC_COMMENT, IDENT, STRING, RAW_STRING)
Diffstat (limited to 'crates/libsyntax2/tests/test/main.rs')
-rw-r--r-- | crates/libsyntax2/tests/test/main.rs | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs index 644df9f3c..ce7e075f8 100644 --- a/crates/libsyntax2/tests/test/main.rs +++ b/crates/libsyntax2/tests/test/main.rs | |||
@@ -33,7 +33,7 @@ fn reparse_test() { | |||
33 | let incrementally_reparsed = { | 33 | let incrementally_reparsed = { |
34 | let f = File::parse(&before); | 34 | let f = File::parse(&before); |
35 | let edit = AtomEdit { delete: range, insert: replace_with.to_string() }; | 35 | let edit = AtomEdit { delete: range, insert: replace_with.to_string() }; |
36 | f.incremental_reparse(&edit).unwrap() | 36 | f.incremental_reparse(&edit).expect("cannot incrementally reparse") |
37 | }; | 37 | }; |
38 | assert_eq_text!( | 38 | assert_eq_text!( |
39 | &dump_tree(fully_reparsed.syntax()), | 39 | &dump_tree(fully_reparsed.syntax()), |
@@ -47,6 +47,11 @@ fn foo() { | |||
47 | } | 47 | } |
48 | ", "baz"); | 48 | ", "baz"); |
49 | do_check(r" | 49 | do_check(r" |
50 | fn foo() { | ||
51 | let x = foo<|> + bar<|> | ||
52 | } | ||
53 | ", "baz"); | ||
54 | do_check(r" | ||
50 | struct Foo { | 55 | struct Foo { |
51 | f: foo<|><|> | 56 | f: foo<|><|> |
52 | } | 57 | } |
@@ -69,6 +74,11 @@ trait Foo { | |||
69 | } | 74 | } |
70 | ", "Output"); | 75 | ", "Output"); |
71 | do_check(r" | 76 | do_check(r" |
77 | trait Foo { | ||
78 | type<|> Foo<|>; | ||
79 | } | ||
80 | ", "Output"); | ||
81 | do_check(r" | ||
72 | impl IntoIterator<Item=i32> for Foo { | 82 | impl IntoIterator<Item=i32> for Foo { |
73 | f<|><|> | 83 | f<|><|> |
74 | } | 84 | } |
@@ -94,6 +104,50 @@ extern { | |||
94 | fn<|>;<|> | 104 | fn<|>;<|> |
95 | } | 105 | } |
96 | ", " exit(code: c_int)"); | 106 | ", " exit(code: c_int)"); |
107 | do_check(r"<|><|> | ||
108 | fn foo() -> i32 { | ||
109 | 1 | ||
110 | } | ||
111 | ", "\n\n\n \n"); | ||
112 | do_check(r" | ||
113 | fn foo() -> <|><|> {} | ||
114 | ", " \n"); | ||
115 | do_check(r" | ||
116 | fn <|>foo<|>() -> i32 { | ||
117 | 1 | ||
118 | } | ||
119 | ", "bar"); | ||
120 | do_check(r" | ||
121 | fn aa<|><|>bb() { | ||
122 | |||
123 | } | ||
124 | ", "foofoo"); | ||
125 | do_check(r" | ||
126 | fn aabb /* <|><|> */ () { | ||
127 | |||
128 | } | ||
129 | ", "some comment"); | ||
130 | do_check(r" | ||
131 | fn aabb <|><|> () { | ||
132 | |||
133 | } | ||
134 | ", " \t\t\n\n"); | ||
135 | do_check(r" | ||
136 | trait foo { | ||
137 | // comment <|><|> | ||
138 | } | ||
139 | ", "\n"); | ||
140 | do_check(r" | ||
141 | /// good <|><|>omment | ||
142 | mod { | ||
143 | } | ||
144 | ", "c"); | ||
145 | do_check(r#" | ||
146 | fn -> &str { "Hello<|><|>" } | ||
147 | "#, ", world"); | ||
148 | do_check(r#" | ||
149 | fn -> &str { // "Hello<|><|>" | ||
150 | "#, ", world"); | ||
97 | } | 151 | } |
98 | 152 | ||
99 | #[test] | 153 | #[test] |