diff options
Diffstat (limited to 'crates/ra_ide_api_light/src/test_utils.rs')
-rw-r--r-- | crates/ra_ide_api_light/src/test_utils.rs | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/crates/ra_ide_api_light/src/test_utils.rs b/crates/ra_ide_api_light/src/test_utils.rs deleted file mode 100644 index bfac0fce3..000000000 --- a/crates/ra_ide_api_light/src/test_utils.rs +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | use ra_syntax::{SourceFile, TextUnit}; | ||
2 | |||
3 | use crate::LocalEdit; | ||
4 | pub use test_utils::*; | ||
5 | |||
6 | pub fn check_action<F: Fn(&SourceFile, TextUnit) -> Option<LocalEdit>>( | ||
7 | before: &str, | ||
8 | after: &str, | ||
9 | f: F, | ||
10 | ) { | ||
11 | let (before_cursor_pos, before) = extract_offset(before); | ||
12 | let file = SourceFile::parse(&before); | ||
13 | let result = f(&file, before_cursor_pos).expect("code action is not applicable"); | ||
14 | let actual = result.edit.apply(&before); | ||
15 | let actual_cursor_pos = match result.cursor_position { | ||
16 | None => result | ||
17 | .edit | ||
18 | .apply_to_offset(before_cursor_pos) | ||
19 | .expect("cursor position is affected by the edit"), | ||
20 | Some(off) => off, | ||
21 | }; | ||
22 | let actual = add_cursor(&actual, actual_cursor_pos); | ||
23 | assert_eq_text!(after, &actual); | ||
24 | } | ||