aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libeditor')
-rw-r--r--crates/libeditor/Cargo.toml2
-rw-r--r--crates/libeditor/tests/test.rs13
2 files changed, 6 insertions, 9 deletions
diff --git a/crates/libeditor/Cargo.toml b/crates/libeditor/Cargo.toml
index 502f532a7..7b39870cd 100644
--- a/crates/libeditor/Cargo.toml
+++ b/crates/libeditor/Cargo.toml
@@ -10,4 +10,6 @@ superslice = "0.1.0"
10 10
11libsyntax2 = { path = "../libsyntax2" } 11libsyntax2 = { path = "../libsyntax2" }
12smol_str = "0.1.0" 12smol_str = "0.1.0"
13
14[dev-dependencies]
13assert_eq_text = { path = "../assert_eq_text" } 15assert_eq_text = { path = "../assert_eq_text" }
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs
index 97919d347..df4cb65d1 100644
--- a/crates/libeditor/tests/test.rs
+++ b/crates/libeditor/tests/test.rs
@@ -6,6 +6,7 @@ extern crate assert_eq_text;
6 6
7use std::fmt; 7use std::fmt;
8use itertools::Itertools; 8use itertools::Itertools;
9use assert_eq_text::{assert_eq_dbg};
9use libeditor::{ 10use libeditor::{
10 File, TextUnit, TextRange, ActionResult, CursorPosition, 11 File, TextUnit, TextRange, ActionResult, CursorPosition,
11 highlight, runnables, extend_selection, file_structure, 12 highlight, runnables, extend_selection, file_structure,
@@ -33,7 +34,7 @@ fn main() {}
33 println!("Hello, {}!", 92); 34 println!("Hello, {}!", 92);
34"#); 35"#);
35 let hls = highlight(&file); 36 let hls = highlight(&file);
36 dbg_eq( 37 assert_eq_dbg(
37 r#"[HighlightedRange { range: [1; 11), tag: "comment" }, 38 r#"[HighlightedRange { range: [1; 11), tag: "comment" },
38 HighlightedRange { range: [12; 14), tag: "keyword" }, 39 HighlightedRange { range: [12; 14), tag: "keyword" },
39 HighlightedRange { range: [15; 19), tag: "function" }, 40 HighlightedRange { range: [15; 19), tag: "function" },
@@ -57,7 +58,7 @@ fn test_foo() {}
57fn test_foo() {} 58fn test_foo() {}
58"#); 59"#);
59 let runnables = runnables(&file); 60 let runnables = runnables(&file);
60 dbg_eq( 61 assert_eq_dbg(
61 r#"[Runnable { range: [1; 13), kind: Bin }, 62 r#"[Runnable { range: [1; 13), kind: Bin },
62 Runnable { range: [15; 39), kind: Test { name: "test_foo" } }, 63 Runnable { range: [15; 39), kind: Test { name: "test_foo" } },
63 Runnable { range: [41; 75), kind: Test { name: "test_foo" } }]"#, 64 Runnable { range: [41; 75), kind: Test { name: "test_foo" } }]"#,
@@ -86,7 +87,7 @@ impl E {}
86impl fmt::Debug for E {} 87impl fmt::Debug for E {}
87"#); 88"#);
88 let symbols = file_structure(&file); 89 let symbols = file_structure(&file);
89 dbg_eq( 90 assert_eq_dbg(
90 r#"[StructureNode { parent: None, label: "Foo", navigation_range: [8; 11), node_range: [1; 26), kind: STRUCT_DEF }, 91 r#"[StructureNode { parent: None, label: "Foo", navigation_range: [8; 11), node_range: [1; 26), kind: STRUCT_DEF },
91 StructureNode { parent: Some(0), label: "x", navigation_range: [18; 19), node_range: [18; 24), kind: NAMED_FIELD }, 92 StructureNode { parent: Some(0), label: "x", navigation_range: [18; 19), node_range: [18; 24), kind: NAMED_FIELD },
92 StructureNode { parent: None, label: "m", navigation_range: [32; 33), node_range: [28; 53), kind: MODULE }, 93 StructureNode { parent: None, label: "m", navigation_range: [32; 33), node_range: [28; 53), kind: MODULE },
@@ -147,12 +148,6 @@ fn file(text: &str) -> File {
147 File::parse(text) 148 File::parse(text)
148} 149}
149 150
150fn dbg_eq(expected: &str, actual: &impl fmt::Debug) {
151 let actual = format!("{:?}", actual);
152 let expected = expected.lines().map(|l| l.trim()).join(" ");
153 assert_eq!(expected, actual);
154}
155
156fn check_action<F: Fn(&File, TextUnit) -> Option<ActionResult>>( 151fn check_action<F: Fn(&File, TextUnit) -> Option<ActionResult>>(
157 before: &str, 152 before: &str,
158 after: &str, 153 after: &str,