mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
generalize folding tests
By using xml-like tags, we will be able to test nested foldings.
This commit is contained in:
parent
61dcaa6add
commit
8d7e8a175e
2 changed files with 52 additions and 28 deletions
|
@ -170,7 +170,7 @@ mod tests {
|
|||
use test_utils::extract_ranges;
|
||||
|
||||
fn do_check(text: &str, fold_kinds: &[FoldKind]) {
|
||||
let (ranges, text) = extract_ranges(text);
|
||||
let (ranges, text) = extract_ranges(text, "fold");
|
||||
let file = SourceFileNode::parse(&text);
|
||||
let folds = folding_ranges(&file);
|
||||
|
||||
|
@ -198,22 +198,22 @@ mod tests {
|
|||
#[test]
|
||||
fn test_fold_comments() {
|
||||
let text = r#"
|
||||
<|>// Hello
|
||||
<fold>// Hello
|
||||
// this is a multiline
|
||||
// comment
|
||||
//<|>
|
||||
//</fold>
|
||||
|
||||
// But this is not
|
||||
|
||||
fn main() {
|
||||
<|>// We should
|
||||
<fold>// We should
|
||||
// also
|
||||
// fold
|
||||
// this one.<|>
|
||||
<|>//! But this one is different
|
||||
//! because it has another flavor<|>
|
||||
<|>/* As does this
|
||||
multiline comment */<|>
|
||||
// this one.</fold>
|
||||
<fold>//! But this one is different
|
||||
//! because it has another flavor</fold>
|
||||
<fold>/* As does this
|
||||
multiline comment */</fold>
|
||||
}"#;
|
||||
|
||||
let fold_kinds = &[
|
||||
|
@ -228,11 +228,11 @@ fn main() {
|
|||
#[test]
|
||||
fn test_fold_imports() {
|
||||
let text = r#"
|
||||
<|>use std::{
|
||||
<fold>use std::{
|
||||
str,
|
||||
vec,
|
||||
io as iop
|
||||
};<|>
|
||||
};</fold>
|
||||
|
||||
fn main() {
|
||||
}"#;
|
||||
|
@ -244,12 +244,12 @@ fn main() {
|
|||
#[test]
|
||||
fn test_fold_import_groups() {
|
||||
let text = r#"
|
||||
<|>use std::str;
|
||||
<fold>use std::str;
|
||||
use std::vec;
|
||||
use std::io as iop;<|>
|
||||
use std::io as iop;</fold>
|
||||
|
||||
<|>use std::mem;
|
||||
use std::f64;<|>
|
||||
<fold>use std::mem;
|
||||
use std::f64;</fold>
|
||||
|
||||
use std::collections::HashMap;
|
||||
// Some random comment
|
||||
|
@ -265,17 +265,17 @@ fn main() {
|
|||
#[test]
|
||||
fn test_fold_import_and_groups() {
|
||||
let text = r#"
|
||||
<|>use std::str;
|
||||
<fold>use std::str;
|
||||
use std::vec;
|
||||
use std::io as iop;<|>
|
||||
use std::io as iop;</fold>
|
||||
|
||||
<|>use std::mem;
|
||||
use std::f64;<|>
|
||||
<fold>use std::mem;
|
||||
use std::f64;</fold>
|
||||
|
||||
<|>use std::collections::{
|
||||
<fold>use std::collections::{
|
||||
HashMap,
|
||||
VecDeque,
|
||||
};<|>
|
||||
};</fold>
|
||||
// Some random comment
|
||||
|
||||
fn main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue