aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-20 19:30:30 +0000
committerAleksey Kladov <[email protected]>2018-12-20 19:30:30 +0000
commit8d7e8a175e6067e4956a23cfd0c1baf003678734 (patch)
tree8c30485c8652cc0c8a7d442744eaead61706c9e6 /crates/ra_editor
parent61dcaa6addcb3fca522b298bdba12239772eb81e (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.rs42
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
208fn main() { 208fn 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
237fn main() { 237fn 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;
248use std::vec; 248use std::vec;
249use std::io as iop;<|> 249use std::io as iop;</fold>
250 250
251<|>use std::mem; 251<fold>use std::mem;
252use std::f64;<|> 252use std::f64;</fold>
253 253
254use std::collections::HashMap; 254use 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;
269use std::vec; 269use std::vec;
270use std::io as iop;<|> 270use std::io as iop;</fold>
271 271
272<|>use std::mem; 272<fold>use std::mem;
273use std::f64;<|> 273use 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
281fn main() { 281fn main() {