aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres/tests.rs
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-05-26 13:11:18 +0100
committerEdwin Cheng <[email protected]>2019-05-26 13:11:18 +0100
commitd6e6a98c03b1a584ed0829bdda24e2c47a742885 (patch)
tree9e7cb2485e3644092a00bda6be9df1c9f1928975 /crates/ra_hir/src/nameres/tests.rs
parentb72074a715cc08b5520c52438c8bb987ddf9038d (diff)
Add Test for new item resolution
Diffstat (limited to 'crates/ra_hir/src/nameres/tests.rs')
-rw-r--r--crates/ra_hir/src/nameres/tests.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index 14c8ee50b..ffb627c02 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -7,6 +7,7 @@ use std::sync::Arc;
7use ra_db::SourceDatabase; 7use ra_db::SourceDatabase;
8use test_utils::covers; 8use test_utils::covers;
9use insta::assert_snapshot_matches; 9use insta::assert_snapshot_matches;
10use either::Either;
10 11
11use crate::{ 12use crate::{
12 Crate, 13 Crate,
@@ -35,10 +36,22 @@ fn render_crate_def_map(map: &CrateDefMap) -> String {
35 *buf += path; 36 *buf += path;
36 *buf += "\n"; 37 *buf += "\n";
37 38
38 let mut entries = map.modules[module].scope.items.iter().collect::<Vec<_>>(); 39 let items =
40 map.modules[module].scope.items.iter().map(|(name, it)| (name, Either::Left(it)));
41 let macros =
42 map.modules[module].scope.macros.iter().map(|(name, m)| (name, Either::Right(m)));
43 let mut entries = items.chain(macros).collect::<Vec<_>>();
44
39 entries.sort_by_key(|(name, _)| *name); 45 entries.sort_by_key(|(name, _)| *name);
40 for (name, res) in entries { 46 for (name, res) in entries {
41 *buf += &format!("{}: {}\n", name, dump_resolution(res)) 47 match res {
48 Either::Left(it) => {
49 *buf += &format!("{}: {}\n", name, dump_resolution(it));
50 }
51 Either::Right(_) => {
52 *buf += &format!("{}: m\n", name);
53 }
54 }
42 } 55 }
43 for (name, child) in map.modules[module].children.iter() { 56 for (name, child) in map.modules[module].children.iter() {
44 let path = path.to_string() + &format!("::{}", name); 57 let path = path.to_string() + &format!("::{}", name);