diff options
| author | Kirill Bulatov <mail4score@gmail.com> | 2020-12-28 15:22:03 +0200 |
|---|---|---|
| committer | Kirill Bulatov <mail4score@gmail.com> | 2020-12-28 15:22:03 +0200 |
| commit | 8600cf807ed25684bbbbac96badf383add43b358 (patch) | |
| tree | 760ad4cd602ce3f4301436baf1af9de39c199dfb | |
| parent | e4c3f753d23752a9fbb01bdf1cd92a8cb1f6681e (diff) | |
Add tests
| -rw-r--r-- | crates/hir_def/src/import_map.rs | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/crates/hir_def/src/import_map.rs b/crates/hir_def/src/import_map.rs index 34a424c601a..fcbb3ac146a 100644 --- a/crates/hir_def/src/import_map.rs +++ b/crates/hir_def/src/import_map.rs @@ -729,7 +729,7 @@ mod tests { } #[test] - fn search() { + fn search_mode() { let ra_fixture = r#" //- /main.rs crate:main deps:dep //- /dep.rs crate:dep deps:tdep @@ -772,7 +772,76 @@ mod tests { check_search( ra_fixture, "main", - Query::new("fmt").name_only().search_mode(SearchMode::Equals), + Query::new("fmt").search_mode(SearchMode::Equals), + expect![[r#" + dep::fmt (t) + dep::Fmt (t) + dep::Fmt (v) + dep::Fmt (m) + dep::fmt::Display (t) + "#]], + ); + + check_search( + ra_fixture, + "main", + Query::new("fmt").search_mode(SearchMode::Contains), + expect![[r#" + dep::fmt (t) + dep::Fmt (t) + dep::Fmt (v) + dep::Fmt (m) + dep::fmt::Display (t) + dep::fmt::Display (t) + "#]], + ); + } + + #[test] + fn name_only() { + let ra_fixture = r#" + //- /main.rs crate:main deps:dep + //- /dep.rs crate:dep deps:tdep + use tdep::fmt as fmt_dep; + pub mod fmt { + pub trait Display { + fn fmt(); + } + } + #[macro_export] + macro_rules! Fmt { + () => {}; + } + pub struct Fmt; + + pub fn format() {} + pub fn no() {} + + //- /tdep.rs crate:tdep + pub mod fmt { + pub struct NotImportableFromMain; + } + "#; + + check_search( + ra_fixture, + "main", + Query::new("fmt"), + expect![[r#" + dep::fmt (t) + dep::Fmt (t) + dep::Fmt (v) + dep::Fmt (m) + dep::fmt::Display (t) + dep::fmt::Display (t) + "#]], + ); + + // TODO kb where does this duplicate `dep::fmt::Display (t)` come from? + check_search( + ra_fixture, + "main", + Query::new("fmt").name_only(), expect