aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-03-07 14:47:10 +0000
committerFlorian Diebold <[email protected]>2020-03-07 14:48:06 +0000
commit8cc4210278c93b9ccf0f825408d0d32bf68617bd (patch)
treea1e2b69a751c441414837c9421c4455153ba4a42 /crates/ra_ide/src/completion
parent24e98121d81b75bafcd9c6005548776c00de8401 (diff)
Add more tests
Diffstat (limited to 'crates/ra_ide/src/completion')
-rw-r--r--crates/ra_ide/src/completion/complete_path.rs33
-rw-r--r--crates/ra_ide/src/completion/complete_pattern.rs18
2 files changed, 51 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs
index 4fa47951a..8c2a28983 100644
--- a/crates/ra_ide/src/completion/complete_path.rs
+++ b/crates/ra_ide/src/completion/complete_path.rs
@@ -835,4 +835,37 @@ mod tests {
835 "### 835 "###
836 ); 836 );
837 } 837 }
838
839 #[test]
840 fn completes_in_simple_macro_call() {
841 let completions = do_reference_completion(
842 r#"
843 macro_rules! m { ($e:expr) => { $e } }
844 fn main() { m!(self::f<|>); }
845 fn foo() {}
846 "#,
847 );
848 assert_debug_snapshot!(completions, @r###"
849 [
850 CompletionItem {
851 label: "foo()",
852 source_range: [93; 94),
853 delete: [93; 94),
854 insert: "foo()$0",
855 kind: Function,
856 lookup: "foo",
857 detail: "fn foo()",
858 },
859 CompletionItem {
860 label: "main()",
861 source_range: [93; 94),
862 delete: [93; 94),
863 insert: "main()$0",
864 kind: Function,
865 lookup: "main",
866 detail: "fn main()",
867 },
868 ]
869 "###);
870 }
838} 871}
diff --git a/crates/ra_ide/src/completion/complete_pattern.rs b/crates/ra_ide/src/completion/complete_pattern.rs
index c2c6ca002..fa8aeceda 100644
--- a/crates/ra_ide/src/completion/complete_pattern.rs
+++ b/crates/ra_ide/src/completion/complete_pattern.rs
@@ -86,4 +86,22 @@ mod tests {
86 ] 86 ]
87 "###); 87 "###);
88 } 88 }
89
90 #[test]
91 fn completes_in_simple_macro_call() {
92 // FIXME: doesn't work yet because of missing error recovery in macro expansion
93 let completions = complete(
94 r"
95 macro_rules! m { ($e:expr) => { $e } }
96 enum E { X }
97
98 fn foo() {
99 m!(match E::X {
100 <|>
101 })
102 }
103 ",
104 );
105 assert_debug_snapshot!(completions, @r###"[]"###);
106 }
89} 107}