aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/test_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libeditor/src/test_utils.rs')
-rw-r--r--crates/libeditor/src/test_utils.rs37
1 files changed, 0 insertions, 37 deletions
diff --git a/crates/libeditor/src/test_utils.rs b/crates/libeditor/src/test_utils.rs
deleted file mode 100644
index 9c1279991..000000000
--- a/crates/libeditor/src/test_utils.rs
+++ /dev/null
@@ -1,37 +0,0 @@
1use libsyntax2::{File, TextUnit, TextRange};
2pub use _test_utils::*;
3use LocalEdit;
4
5pub fn check_action<F: Fn(&File, TextUnit) -> Option<LocalEdit>> (
6 before: &str,
7 after: &str,
8 f: F,
9) {
10 let (before_cursor_pos, before) = extract_offset(before);
11 let file = File::parse(&before);
12 let result = f(&file, before_cursor_pos).expect("code action is not applicable");
13 let actual = result.edit.apply(&before);
14 let actual_cursor_pos = match result.cursor_position {
15 None => result.edit.apply_to_offset(before_cursor_pos).unwrap(),
16 Some(off) => off,
17 };
18 let actual = add_cursor(&actual, actual_cursor_pos);
19 assert_eq_text!(after, &actual);
20}
21
22pub fn check_action_range<F: Fn(&File, TextRange) -> Option<LocalEdit>> (
23 before: &str,
24 after: &str,
25 f: F,
26) {
27 let (range, before) = extract_range(before);
28 let file = File::parse(&before);
29 let result = f(&file, range).expect("code action is not applicable");
30 let actual = result.edit.apply(&before);
31 let actual_cursor_pos = match result.cursor_position {
32 None => result.edit.apply_to_offset(range.start()).unwrap(),
33 Some(off) => off,
34 };
35 let actual = add_cursor(&actual, actual_cursor_pos);
36 assert_eq_text!(after, &actual);
37}