aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/tests/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libeditor/tests/test.rs')
-rw-r--r--crates/libeditor/tests/test.rs25
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
4use std::fmt; 4use std::fmt;
5use itertools::Itertools; 5use itertools::Itertools;
6use libeditor::{File, highlight, runnables, extend_selection, TextRange}; 6use libeditor::{File, highlight, runnables, extend_selection, TextRange, file_symbols};
7 7
8#[test] 8#[test]
9fn test_extend_selection() { 9fn test_extend_selection() {
@@ -58,6 +58,29 @@ fn test_foo() {}
58 ) 58 )
59} 59}
60 60
61#[test]
62fn symbols() {
63 let file = file(r#"
64struct Foo {
65 x: i32
66}
67
68mod m {
69 fn bar() {}
70}
71
72enum 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
61fn file(text: &str) -> File { 84fn file(text: &str) -> File {
62 File::parse(text) 85 File::parse(text)
63} 86}