From 072ec1a8ae7271324a907ea082521226a6f3d1d4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 4 Mar 2020 12:20:32 +0100 Subject: Fix tests --- crates/ra_ide/src/references.rs | 30 ++++++++++++++---------------- crates/ra_ide_db/src/marks.rs | 1 + crates/ra_ide_db/src/search.rs | 3 ++- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 6440707d7..8eba13e99 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -287,7 +287,7 @@ mod tests { #[test] fn search_filters_by_range() { - covers!(search_filters_by_range); + covers!(ra_ide_db::search_filters_by_range); let code = r#" fn foo() { let spam<|> = 92; @@ -603,7 +603,10 @@ mod tests { fn check_result(res: ReferenceSearchResult, expected_decl: &str, expected_refs: &[&str]) { res.declaration().assert_match(expected_decl); assert_eq!(res.references.len(), expected_refs.len()); - res.references().iter().enumerate().for_each(|(i, r)| r.assert_match(expected_refs[i])); + res.references() + .iter() + .enumerate() + .for_each(|(i, r)| ref_assert_match(r, expected_refs[i])); } impl Declaration { @@ -621,21 +624,16 @@ mod tests { } } - impl Reference { - fn debug_render(&self) -> String { - let mut s = format!( - "{:?} {:?} {:?}", - self.file_range.file_id, self.file_range.range, self.kind - ); - if let Some(access) = self.access { - s.push_str(&format!(" {:?}", access)); - } - s + fn ref_debug_render(r: &Reference) -> String { + let mut s = format!("{:?} {:?} {:?}", r.file_range.file_id, r.file_range.range, r.kind); + if let Some(access) = r.access { + s.push_str(&format!(" {:?}", access)); } + s + } - fn assert_match(&self, expected: &str) { - let actual = self.debug_render(); - test_utils::assert_eq_text!(expected.trim(), actual.trim(),); - } + fn ref_assert_match(r: &Reference, expected: &str) { + let actual = ref_debug_render(r); + test_utils::assert_eq_text!(expected.trim(), actual.trim(),); } } diff --git a/crates/ra_ide_db/src/marks.rs b/crates/ra_ide_db/src/marks.rs index d088fa257..4f0a22af0 100644 --- a/crates/ra_ide_db/src/marks.rs +++ b/crates/ra_ide_db/src/marks.rs @@ -6,4 +6,5 @@ test_utils::marks![ goto_def_for_fields goto_def_for_record_fields goto_def_for_field_init_shorthand + search_filters_by_range ]; diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 23dd278b5..0963ea257 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -12,6 +12,7 @@ use ra_syntax::{ algo::find_node_at_offset, ast, match_ast, AstNode, TextRange, TextUnit, TokenAtOffset, }; use rustc_hash::FxHashMap; +use test_utils::tested_by; use crate::{ defs::{classify_name_ref, Definition}, @@ -206,7 +207,7 @@ impl Definition { for (idx, _) in text.match_indices(pat) { let offset = TextUnit::from_usize(idx); if !search_range.contains_inclusive(offset) { - // tested_by!(search_filters_by_range); + tested_by!(search_filters_by_range; force); continue; } -- cgit v1.2.3