Skip to content

Commit 8471da6

Browse files
committed
Compress tests
1 parent 7066e6b commit 8471da6

File tree

2 files changed

+424
-616
lines changed

2 files changed

+424
-616
lines changed

crates/ide_assists/src/tests.rs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use ide_db::{
1212
RootDatabase,
1313
};
1414
use stdx::{format_to, trim_indent};
15-
use syntax::{ast, AstNode, TextRange};
15+
use syntax::TextRange;
1616
use test_utils::{assert_eq_text, extract_offset};
1717

1818
use crate::{handlers::Handler, Assist, AssistConfig, AssistContext, AssistKind, Assists};
@@ -180,50 +180,6 @@ fn labels(assists: &[Assist]) -> String {
180180
labels.into_iter().collect::<String>()
181181
}
182182

183-
pub(crate) type NameSuggestion = fn(&ast::Expr, &Semantics<'_, RootDatabase>) -> Option<String>;
184-
185-
#[track_caller]
186-
pub(crate) fn check_name_suggestion(
187-
suggestion: NameSuggestion,
188-
ra_fixture: &str,
189-
suggested_name: &str,
190-
) {
191-
check_name(suggestion, ra_fixture, Some(suggested_name));
192-
}
193-
194-
#[track_caller]
195-
pub(crate) fn check_name_suggestion_not_applicable(suggestion: NameSuggestion, ra_fixture: &str) {
196-
check_name(suggestion, ra_fixture, None);
197-
}
198-
199-
#[track_caller]
200-
fn check_name(suggestion: NameSuggestion, ra_fixture: &str, expected: Option<&str>) {
201-
let (db, file_with_carret_id, range_or_offset) = RootDatabase::with_range_or_offset(ra_fixture);
202-
let frange = FileRange { file_id: file_with_carret_id, range: range_or_offset.into() };
203-
204-
let sema = Semantics::new(&db);
205-
let source_file = sema.parse(frange.file_id);
206-
let element = source_file.syntax().covering_element(frange.range);
207-
let expr =
208-
element.ancestors().find_map(ast::Expr::cast).expect("selection is not an expression");
209-
assert_eq!(
210-
expr.syntax().text_range(),
211-
frange.range,
212-
"selection is not an expression(yet contained in one)"
213-
);
214-
215-
let name = suggestion(&expr, &sema);
216-
217-
match (name, expected) {
218-
(Some(name), Some(expected_name)) => {
219-
assert_eq_text!(&name, expected_name);
220-
}
221-
(Some(_), None) => panic!("name suggestion should not be applicable"),
222-
(None, Some(_)) => panic!("name suggestion is not applicable"),
223-
(None, None) => (),
224-
}
225-
}
226-
227183
#[test]
228184
fn assist_order_field_struct() {
229185
let before = "struct Foo { $0bar: u32 }";

0 commit comments

Comments
 (0)