aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-12-28 13:22:03 +0000
committerKirill Bulatov <[email protected]>2020-12-28 13:22:03 +0000
commit8600cf807ed25684bbbbac96badf383add43b358 (patch)
tree760ad4cd602ce3f4301436baf1af9de39c199dfb /crates
parente4c3f753d23752a9fbb01bdf1cd92a8cb1f6681e (diff)
Add tests
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/import_map.rs73
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 34a424c60..fcbb3ac14 100644
--- a/crates/hir_def/src/import_map.rs
+++ b/crates/hir_def/src/import_map.rs
@@ -729,7 +729,7 @@ mod tests {
729 } 729 }
730 730
731 #[test] 731 #[test]
732 fn search() { 732 fn search_mode() {
733 let ra_fixture = r#" 733 let ra_fixture = r#"
734 //- /main.rs crate:main deps:dep 734 //- /main.rs crate:main deps:dep
735 //- /dep.rs crate:dep deps:tdep 735 //- /dep.rs crate:dep deps:tdep
@@ -772,7 +772,76 @@ mod tests {
772 check_search( 772 check_search(
773 ra_fixture, 773 ra_fixture,
774 "main", 774 "main",
775 Query::new("fmt").name_only().search_mode(SearchMode::Equals), 775 Query::new("fmt").search_mode(SearchMode::Equals),
776 expect![[r#"
777 dep::fmt (t)
778 dep::Fmt (t)
779 dep::Fmt (v)
780 dep::Fmt (m)
781 dep::fmt::Display (t)
782 "#]],
783 );
784
785 check_search(
786 ra_fixture,
787 "main",
788 Query::new("fmt").search_mode(SearchMode::Contains),
789 expect![[r#"
790 dep::fmt (t)
791 dep::Fmt (t)
792 dep::Fmt (v)
793 dep::Fmt (m)
794 dep::fmt::Display (t)
795 dep::fmt::Display (t)
796 "#]],
797 );
798 }
799
800 #[test]
801 fn name_only() {
802 let ra_fixture = r#"
803 //- /main.rs crate:main deps:dep
804 //- /dep.rs crate:dep deps:tdep
805 use tdep::fmt as fmt_dep;
806 pub mod fmt {
807 pub trait Display {
808 fn fmt();
809 }
810 }
811 #[macro_export]
812 macro_rules! Fmt {
813 () => {};
814 }
815 pub struct Fmt;
816
817 pub fn format() {}
818 pub fn no() {}
819
820 //- /tdep.rs crate:tdep
821 pub mod fmt {
822 pub struct NotImportableFromMain;
823 }
824 "#;
825
826 check_search(
827 ra_fixture,
828 "main",
829 Query::new("fmt"),
830 expect![[r#"
831 dep::fmt (t)
832 dep::Fmt (t)
833 dep::Fmt (v)
834 dep::Fmt (m)
835 dep::fmt::Display (t)
836 dep::fmt::Display (t)
837 "#]],
838 );
839
840 // TODO kb where does this duplicate `dep::fmt::Display (t)` come from?
841 check_search(
842 ra_fixture,
843 "main",
844 Query::new("fmt").name_only(),
776 expect![[r#" 845 expect![[r#"
777 dep::fmt (t) 846 dep::fmt (t)
778 dep::Fmt (t) 847 dep::Fmt (t)