aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libeditor/tests')
-rw-r--r--crates/libeditor/tests/test.rs13
1 files changed, 4 insertions, 9 deletions
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,