diff options
author | Aleksey Kladov <[email protected]> | 2018-08-17 14:04:34 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-17 14:04:34 +0100 |
commit | 41570f60bf268c97223a864b8aa11a339929f55a (patch) | |
tree | 1eabe16612f975a0e6bfeede79dcfea98d2b3aa4 /crates/libeditor/tests | |
parent | 081c16c77642a5c86ed72c5fbd11deccc2edd5d5 (diff) |
extend module resolve to mod.rs
Diffstat (limited to 'crates/libeditor/tests')
-rw-r--r-- | crates/libeditor/tests/test.rs | 13 |
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 | ||
7 | use std::fmt; | 7 | use std::fmt; |
8 | use itertools::Itertools; | 8 | use itertools::Itertools; |
9 | use assert_eq_text::{assert_eq_dbg}; | ||
9 | use libeditor::{ | 10 | use 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() {} | |||
57 | fn test_foo() {} | 58 | fn 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 {} | |||
86 | impl fmt::Debug for E {} | 87 | impl 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 | ||
150 | fn 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 | |||
156 | fn check_action<F: Fn(&File, TextUnit) -> Option<ActionResult>>( | 151 | fn check_action<F: Fn(&File, TextUnit) -> Option<ActionResult>>( |
157 | before: &str, | 152 | before: &str, |
158 | after: &str, | 153 | after: &str, |