aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-04 11:20:32 +0000
committerAleksey Kladov <[email protected]>2020-03-04 11:24:28 +0000
commit072ec1a8ae7271324a907ea082521226a6f3d1d4 (patch)
tree7f5de3065ecf92c93eed0b03effa563ff3aa0b44 /crates/ra_ide
parent994000b5ddfd5bb3b7dc7d66aabe02a0f337770f (diff)
Fix tests
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/references.rs30
1 files changed, 14 insertions, 16 deletions
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 {
287 287
288 #[test] 288 #[test]
289 fn search_filters_by_range() { 289 fn search_filters_by_range() {
290 covers!(search_filters_by_range); 290 covers!(ra_ide_db::search_filters_by_range);
291 let code = r#" 291 let code = r#"
292 fn foo() { 292 fn foo() {
293 let spam<|> = 92; 293 let spam<|> = 92;
@@ -603,7 +603,10 @@ mod tests {
603 fn check_result(res: ReferenceSearchResult, expected_decl: &str, expected_refs: &[&str]) { 603 fn check_result(res: ReferenceSearchResult, expected_decl: &str, expected_refs: &[&str]) {
604 res.declaration().assert_match(expected_decl); 604 res.declaration().assert_match(expected_decl);
605 assert_eq!(res.references.len(), expected_refs.len()); 605 assert_eq!(res.references.len(), expected_refs.len());
606 res.references().iter().enumerate().for_each(|(i, r)| r.assert_match(expected_refs[i])); 606 res.references()
607 .iter()
608 .enumerate()
609 .for_each(|(i, r)| ref_assert_match(r, expected_refs[i]));
607 } 610 }
608 611
609 impl Declaration { 612 impl Declaration {
@@ -621,21 +624,16 @@ mod tests {
621 } 624 }
622 } 625 }
623 626
624 impl Reference { 627 fn ref_debug_render(r: &Reference) -> String {
625 fn debug_render(&self) -> String { 628 let mut s = format!("{:?} {:?} {:?}", r.file_range.file_id, r.file_range.range, r.kind);
626 let mut s = format!( 629 if let Some(access) = r.access {
627 "{:?} {:?} {:?}", 630 s.push_str(&format!(" {:?}", access));
628 self.file_range.file_id, self.file_range.range, self.kind
629 );
630 if let Some(access) = self.access {
631 s.push_str(&format!(" {:?}", access));
632 }
633 s
634 } 631 }
632 s
633 }
635 634
636 fn assert_match(&self, expected: &str) { 635 fn ref_assert_match(r: &Reference, expected: &str) {
637 let actual = self.debug_render(); 636 let actual = ref_debug_render(r);
638 test_utils::assert_eq_text!(expected.trim(), actual.trim(),); 637 test_utils::assert_eq_text!(expected.trim(), actual.trim(),);
639 }
640 } 638 }
641} 639}