diff options
Diffstat (limited to 'crates/libeditor/tests/test.rs')
-rw-r--r-- | crates/libeditor/tests/test.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index d617f4b99..ba7181ab8 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs | |||
@@ -3,7 +3,7 @@ extern crate itertools; | |||
3 | 3 | ||
4 | use std::fmt; | 4 | use std::fmt; |
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | use libeditor::{File, highlight, runnables, extend_selection, TextRange}; | 6 | use libeditor::{File, highlight, runnables, extend_selection, TextRange, file_symbols}; |
7 | 7 | ||
8 | #[test] | 8 | #[test] |
9 | fn test_extend_selection() { | 9 | fn test_extend_selection() { |
@@ -58,6 +58,29 @@ fn test_foo() {} | |||
58 | ) | 58 | ) |
59 | } | 59 | } |
60 | 60 | ||
61 | #[test] | ||
62 | fn symbols() { | ||
63 | let file = file(r#" | ||
64 | struct Foo { | ||
65 | x: i32 | ||
66 | } | ||
67 | |||
68 | mod m { | ||
69 | fn bar() {} | ||
70 | } | ||
71 | |||
72 | enum E { X, Y(i32) } | ||
73 | "#); | ||
74 | let symbols = file_symbols(&file); | ||
75 | dbg_eq( | ||
76 | &symbols, | ||
77 | r#"[FileSymbol { parent: None, name: "Foo", name_range: [8; 11), node_range: [1; 26), kind: STRUCT }, | ||
78 | FileSymbol { parent: None, name: "m", name_range: [32; 33), node_range: [28; 53), kind: MODULE }, | ||
79 | FileSymbol { parent: Some(1), name: "bar", name_range: [43; 46), node_range: [40; 51), kind: FUNCTION }, | ||
80 | FileSymbol { parent: None, name: "E", name_range: [60; 61), node_range: [55; 75), kind: ENUM }]"#, | ||
81 | ) | ||
82 | } | ||
83 | |||
61 | fn file(text: &str) -> File { | 84 | fn file(text: &str) -> File { |
62 | File::parse(text) | 85 | File::parse(text) |
63 | } | 86 | } |