aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libeditor/tests')
-rw-r--r--crates/libeditor/tests/test.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs
index fab2e4ad3..97fa30e1f 100644
--- a/crates/libeditor/tests/test.rs
+++ b/crates/libeditor/tests/test.rs
@@ -9,7 +9,7 @@ use itertools::Itertools;
9use libsyntax2::AstNode; 9use libsyntax2::AstNode;
10use libeditor::{ 10use libeditor::{
11 File, TextUnit, TextRange, 11 File, TextUnit, TextRange,
12 highlight, runnables, extend_selection, file_symbols, flip_comma, 12 highlight, runnables, extend_selection, file_structure, flip_comma,
13}; 13};
14 14
15#[test] 15#[test]
@@ -66,7 +66,7 @@ fn test_foo() {}
66} 66}
67 67
68#[test] 68#[test]
69fn symbols() { 69fn test_structure() {
70 let file = file(r#" 70 let file = file(r#"
71struct Foo { 71struct Foo {
72 x: i32 72 x: i32
@@ -80,16 +80,22 @@ enum E { X, Y(i32) }
80type T = (); 80type T = ();
81static S: i32 = 92; 81static S: i32 = 92;
82const C: i32 = 92; 82const C: i32 = 92;
83
84impl E {}
85
86impl fmt::Debug for E {}
83"#); 87"#);
84 let symbols = file_symbols(&file); 88 let symbols = file_structure(&file);
85 dbg_eq( 89 dbg_eq(
86 r#"[FileSymbol { parent: None, name: "Foo", name_range: [8; 11), node_range: [1; 26), kind: STRUCT_DEF }, 90 r#"[StructureNode { parent: None, label: "Foo", navigation_range: [8; 11), node_range: [1; 26), kind: STRUCT_DEF },
87 FileSymbol { parent: None, name: "m", name_range: [32; 33), node_range: [28; 53), kind: MODULE }, 91 StructureNode { parent: None, label: "m", navigation_range: [32; 33), node_range: [28; 53), kind: MODULE },
88 FileSymbol { parent: Some(1), name: "bar", name_range: [43; 46), node_range: [40; 51), kind: FN_DEF }, 92 StructureNode { parent: Some(1), label: "bar", navigation_range: [43; 46), node_range: [40; 51), kind: FN_DEF },
89 FileSymbol { parent: None, name: "E", name_range: [60; 61), node_range: [55; 75), kind: ENUM_DEF }, 93 StructureNode { parent: None, label: "E", navigation_range: [60; 61), node_range: [55; 75), kind: ENUM_DEF },
90 FileSymbol { parent: None, name: "T", name_range: [81; 82), node_range: [76; 88), kind: TYPE_DEF }, 94 StructureNode { parent: None, label: "T", navigation_range: [81; 82), node_range: [76; 88), kind: TYPE_DEF },
91 FileSymbol { parent: None, name: "S", name_range: [96; 97), node_range: [89; 108), kind: STATIC_DEF }, 95 StructureNode { parent: None, label: "S", navigation_range: [96; 97), node_range: [89; 108), kind: STATIC_DEF },
92 FileSymbol { parent: None, name: "C", name_range: [115; 116), node_range: [109; 127), kind: CONST_DEF }]"#, 96 StructureNode { parent: None, label: "C", navigation_range: [115; 116), node_range: [109; 127), kind: CONST_DEF },
97 StructureNode { parent: None, label: "impl E ", navigation_range: [129; 136), node_range: [129; 138), kind: IMPL_ITEM },
98 StructureNode { parent: None, label: "impl fmt::Debug for E ", navigation_range: [140; 162), node_range: [140; 164), kind: IMPL_ITEM }]"#,
93 &symbols, 99 &symbols,
94 ) 100 )
95} 101}