diff options
author | Aleksey Kladov <[email protected]> | 2018-12-20 19:30:30 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-20 19:30:30 +0000 |
commit | 8d7e8a175e6067e4956a23cfd0c1baf003678734 (patch) | |
tree | 8c30485c8652cc0c8a7d442744eaead61706c9e6 /crates/ra_editor | |
parent | 61dcaa6addcb3fca522b298bdba12239772eb81e (diff) |
generalize folding tests
By using xml-like tags, we will be able to test nested foldings.
Diffstat (limited to 'crates/ra_editor')
-rw-r--r-- | crates/ra_editor/src/folding_ranges.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs index 2a8fa3cda..a4add8702 100644 --- a/crates/ra_editor/src/folding_ranges.rs +++ b/crates/ra_editor/src/folding_ranges.rs | |||
@@ -170,7 +170,7 @@ mod tests { | |||
170 | use test_utils::extract_ranges; | 170 | use test_utils::extract_ranges; |
171 | 171 | ||
172 | fn do_check(text: &str, fold_kinds: &[FoldKind]) { | 172 | fn do_check(text: &str, fold_kinds: &[FoldKind]) { |
173 | let (ranges, text) = extract_ranges(text); | 173 | let (ranges, text) = extract_ranges(text, "fold"); |
174 | let file = SourceFileNode::parse(&text); | 174 | let file = SourceFileNode::parse(&text); |
175 | let folds = folding_ranges(&file); | 175 | let folds = folding_ranges(&file); |
176 | 176 | ||
@@ -198,22 +198,22 @@ mod tests { | |||
198 | #[test] | 198 | #[test] |
199 | fn test_fold_comments() { | 199 | fn test_fold_comments() { |
200 | let text = r#" | 200 | let text = r#" |
201 | <|>// Hello | 201 | <fold>// Hello |
202 | // this is a multiline | 202 | // this is a multiline |
203 | // comment | 203 | // comment |
204 | //<|> | 204 | //</fold> |
205 | 205 | ||
206 | // But this is not | 206 | // But this is not |
207 | 207 | ||
208 | fn main() { | 208 | fn main() { |
209 | <|>// We should | 209 | <fold>// We should |
210 | // also | 210 | // also |
211 | // fold | 211 | // fold |
212 | // this one.<|> | 212 | // this one.</fold> |
213 | <|>//! But this one is different | 213 | <fold>//! But this one is different |
214 | //! because it has another flavor<|> | 214 | //! because it has another flavor</fold> |
215 | <|>/* As does this | 215 | <fold>/* As does this |
216 | multiline comment */<|> | 216 | multiline comment */</fold> |
217 | }"#; | 217 | }"#; |
218 | 218 | ||
219 | let fold_kinds = &[ | 219 | let fold_kinds = &[ |
@@ -228,11 +228,11 @@ fn main() { | |||
228 | #[test] | 228 | #[test] |
229 | fn test_fold_imports() { | 229 | fn test_fold_imports() { |
230 | let text = r#" | 230 | let text = r#" |
231 | <|>use std::{ | 231 | <fold>use std::{ |
232 | str, | 232 | str, |
233 | vec, | 233 | vec, |
234 | io as iop | 234 | io as iop |
235 | };<|> | 235 | };</fold> |
236 | 236 | ||
237 | fn main() { | 237 | fn main() { |
238 | }"#; | 238 | }"#; |
@@ -244,12 +244,12 @@ fn main() { | |||
244 | #[test] | 244 | #[test] |
245 | fn test_fold_import_groups() { | 245 | fn test_fold_import_groups() { |
246 | let text = r#" | 246 | let text = r#" |
247 | <|>use std::str; | 247 | <fold>use std::str; |
248 | use std::vec; | 248 | use std::vec; |
249 | use std::io as iop;<|> | 249 | use std::io as iop;</fold> |
250 | 250 | ||
251 | <|>use std::mem; | 251 | <fold>use std::mem; |
252 | use std::f64;<|> | 252 | use std::f64;</fold> |
253 | 253 | ||
254 | use std::collections::HashMap; | 254 | use std::collections::HashMap; |
255 | // Some random comment | 255 | // Some random comment |
@@ -265,17 +265,17 @@ fn main() { | |||
265 | #[test] | 265 | #[test] |
266 | fn test_fold_import_and_groups() { | 266 | fn test_fold_import_and_groups() { |
267 | let text = r#" | 267 | let text = r#" |
268 | <|>use std::str; | 268 | <fold>use std::str; |
269 | use std::vec; | 269 | use std::vec; |
270 | use std::io as iop;<|> | 270 | use std::io as iop;</fold> |
271 | 271 | ||
272 | <|>use std::mem; | 272 | <fold>use std::mem; |
273 | use std::f64;<|> | 273 | use std::f64;</fold> |
274 | 274 | ||
275 | <|>use std::collections::{ | 275 | <fold>use std::collections::{ |
276 | HashMap, | 276 | HashMap, |
277 | VecDeque, | 277 | VecDeque, |
278 | };<|> | 278 | };</fold> |
279 | // Some random comment | 279 | // Some random comment |
280 | 280 | ||
281 | fn main() { | 281 | fn main() { |