aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/tests.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs
index 49837d60b..858f5ca80 100644
--- a/crates/ra_assists/src/tests.rs
+++ b/crates/ra_assists/src/tests.rs
@@ -4,7 +4,7 @@ use hir::Semantics;
4use ra_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; 4use ra_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt};
5use ra_ide_db::RootDatabase; 5use ra_ide_db::RootDatabase;
6use ra_syntax::TextRange; 6use ra_syntax::TextRange;
7use test_utils::{assert_eq_text, extract_offset, extract_range, extract_range_or_offset}; 7use test_utils::{assert_eq_text, extract_offset, extract_range};
8 8
9use crate::{handlers::Handler, Assist, AssistConfig, AssistContext, Assists}; 9use crate::{handlers::Handler, Assist, AssistConfig, AssistContext, Assists};
10use stdx::trim_indent; 10use stdx::trim_indent;
@@ -30,8 +30,9 @@ pub(crate) fn check_assist_not_applicable(assist: Handler, ra_fixture: &str) {
30} 30}
31 31
32fn check_doc_test(assist_id: &str, before: &str, after: &str) { 32fn check_doc_test(assist_id: &str, before: &str, after: &str) {
33 let (selection, before) = extract_range_or_offset(before); 33 let after = trim_indent(after);
34 let (db, file_id) = crate::tests::with_single_file(&before); 34 let (db, file_id, selection) = RootDatabase::with_range_or_offset(&before);
35 let before = db.file_text(file_id).to_string();
35 let frange = FileRange { file_id, range: selection.into() }; 36 let frange = FileRange { file_id, range: selection.into() };
36 37
37 let mut assist = Assist::resolved(&db, &AssistConfig::default(), frange) 38 let mut assist = Assist::resolved(&db, &AssistConfig::default(), frange)
@@ -51,11 +52,11 @@ fn check_doc_test(assist_id: &str, before: &str, after: &str) {
51 52
52 let actual = { 53 let actual = {
53 let change = assist.source_change.source_file_edits.pop().unwrap(); 54 let change = assist.source_change.source_file_edits.pop().unwrap();
54 let mut actual = before.clone(); 55 let mut actual = before;
55 change.edit.apply(&mut actual); 56 change.edit.apply(&mut actual);
56 actual 57 actual
57 }; 58 };
58 assert_eq_text!(after, &actual); 59 assert_eq_text!(&after, &actual);
59} 60}
60 61
61enum ExpectedResult<'a> { 62enum ExpectedResult<'a> {
@@ -66,7 +67,7 @@ enum ExpectedResult<'a> {
66 67
67fn check(handler: Handler, before: &str, expected: ExpectedResult) { 68fn check(handler: Handler, before: &str, expected: ExpectedResult) {
68 let (db, file_with_caret_id, range_or_offset) = RootDatabase::with_range_or_offset(before); 69 let (db, file_with_caret_id, range_or_offset) = RootDatabase::with_range_or_offset(before);
69 let text_without_caret = db.file_text(file_with_caret_id).as_ref().to_owned(); 70 let text_without_caret = db.file_text(file_with_caret_id).to_string();
70 71
71 let frange = FileRange { file_id: file_with_caret_id, range: range_or_offset.into() }; 72 let frange = FileRange { file_id: file_with_caret_id, range: range_or_offset.into() };
72 73