diff options
author | Mikhail Rakhmanov <[email protected]> | 2020-06-12 19:30:57 +0100 |
---|---|---|
committer | Mikhail Rakhmanov <[email protected]> | 2020-06-12 19:30:57 +0100 |
commit | 357667104371d446cc029267e8095365c17ba085 (patch) | |
tree | 078b56f8e1fba04aad022880833a5d2c5ee858b7 /crates/ra_ide/src/completion/patterns.rs | |
parent | 42a719ad255c62933f58c2b2a5e767fb3b3c5a26 (diff) |
Rewrite snapshot checks
Diffstat (limited to 'crates/ra_ide/src/completion/patterns.rs')
-rw-r--r-- | crates/ra_ide/src/completion/patterns.rs | 84 |
1 files changed, 10 insertions, 74 deletions
diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs index 25be0c307..bc39689ab 100644 --- a/crates/ra_ide/src/completion/patterns.rs +++ b/crates/ra_ide/src/completion/patterns.rs | |||
@@ -121,115 +121,51 @@ mod tests { | |||
121 | 121 | ||
122 | #[test] | 122 | #[test] |
123 | fn test_unsafe_is_prev() { | 123 | fn test_unsafe_is_prev() { |
124 | check_pattern_is_applicable( | 124 | check_pattern_is_applicable(r"unsafe i<|>", unsafe_is_prev); |
125 | r" | ||
126 | unsafe i<|> | ||
127 | ", | ||
128 | unsafe_is_prev, | ||
129 | ); | ||
130 | } | 125 | } |
131 | 126 | ||
132 | #[test] | 127 | #[test] |
133 | fn test_if_is_prev() { | 128 | fn test_if_is_prev() { |
134 | check_pattern_is_applicable( | 129 | check_pattern_is_applicable(r"if l<|>", if_is_prev); |
135 | r" | ||
136 | if l<|> | ||
137 | ", | ||
138 | if_is_prev, | ||
139 | ); | ||
140 | } | 130 | } |
141 | 131 | ||
142 | #[test] | 132 | #[test] |
143 | fn test_inside_trait() { | 133 | fn test_inside_trait() { |
144 | check_pattern_is_applicable( | 134 | check_pattern_is_applicable(r"trait A { fn<|> }", inside_trait); |
145 | r" | ||
146 | trait A { | ||
147 | fn<|> | ||
148 | } | ||
149 | ", | ||
150 | inside_trait, | ||
151 | ); | ||
152 | } | 135 | } |
153 | 136 | ||
154 | #[test] | 137 | #[test] |
155 | fn test_has_trait_as_prev_sibling() { | 138 | fn test_has_trait_as_prev_sibling() { |
156 | check_pattern_is_applicable( | 139 | check_pattern_is_applicable(r"trait A w<|> {}", has_trait_as_prev_sibling); |
157 | r" | ||
158 | trait A w<|> { | ||
159 | } | ||
160 | ", | ||
161 | has_trait_as_prev_sibling, | ||
162 | ); | ||
163 | } | 140 | } |
164 | 141 | ||
165 | #[test] | 142 | #[test] |
166 | fn test_has_impl_as_prev_sibling() { | 143 | fn test_has_impl_as_prev_sibling() { |
167 | check_pattern_is_applicable( | 144 | check_pattern_is_applicable(r"impl A w<|> {}", has_impl_as_prev_sibling); |
168 | r" | ||
169 | impl A w<|> { | ||
170 | } | ||
171 | ", | ||
172 | has_impl_as_prev_sibling, | ||
173 | ); | ||
174 | } | 145 | } |
175 | 146 | ||
176 | #[test] | 147 | #[test] |
177 | fn test_parent_block_expr() { | 148 | fn test_parent_block_expr() { |
178 | check_pattern_is_applicable( | 149 | check_pattern_is_applicable(r"fn my_fn() { let a = 2; f<|> }", has_block_expr_parent); |
179 | r" | ||
180 | fn my_fn() { | ||
181 | let a = 2; | ||
182 | f<|> | ||
183 | } | ||
184 | ", | ||
185 | has_block_expr_parent, | ||
186 | ); | ||
187 | } | 150 | } |
188 | 151 | ||
189 | #[test] | 152 | #[test] |
190 | fn test_has_ref_pat_parent_in_func_parameters() { | 153 | fn test_has_ref_pat_parent_in_func_parameters() { |
191 | check_pattern_is_applicable( | 154 | check_pattern_is_applicable(r"fn my_fn(&<|>) {}", has_ref_pat_parent); |
192 | r" | ||
193 | fn my_fn(&<|>) { | ||
194 | let a = 2; | ||
195 | } | ||
196 | ", | ||
197 | has_ref_pat_parent, | ||
198 | ); | ||
199 | } | 155 | } |
200 | 156 | ||
201 | #[test] | 157 | #[test] |
202 | fn test_has_ref_pat_parent_in_let_statement() { | 158 | fn test_has_ref_pat_parent_in_let_statement() { |
203 | check_pattern_is_applicable( | 159 | check_pattern_is_applicable(r"fn my_fn() { let &<|> }", has_ref_pat_parent); |
204 | r" | ||
205 | fn my_fn() { | ||
206 | let &<|> | ||
207 | } | ||
208 | ", | ||
209 | has_ref_pat_parent, | ||
210 | ); | ||
211 | } | 160 | } |
212 | 161 | ||
213 | #[test] | 162 | #[test] |
214 | fn test_has_bind_pat_parent_in_func_parameters() { | 163 | fn test_has_bind_pat_parent_in_func_parameters() { |
215 | check_pattern_is_applicable( | 164 | check_pattern_is_applicable(r"fn my_fn(m<|>) {}", has_bind_pat_parent); |
216 | r" | ||
217 | fn my_fn(m<|>) { | ||
218 | } | ||
219 | ", | ||
220 | has_bind_pat_parent, | ||
221 | ); | ||
222 | } | 165 | } |
223 | 166 | ||
224 | #[test] | 167 | #[test] |
225 | fn test_has_bind_pat_parent_in_let_statement() { | 168 | fn test_has_bind_pat_parent_in_let_statement() { |
226 | check_pattern_is_applicable( | 169 | check_pattern_is_applicable(r"fn my_fn() { let m<|> }", has_bind_pat_parent); |
227 | r" | ||
228 | fn my_fn() { | ||
229 | let m<|> | ||
230 | } | ||
231 | ", | ||
232 | has_bind_pat_parent, | ||
233 | ); | ||
234 | } | 170 | } |
235 | } | 171 | } |