From a5a07bde049c59059bc4a68b16a49a174d22cf65 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 2 Dec 2019 19:27:31 +0100 Subject: Add tests for checking the impl self type --- crates/ra_ide/src/completion/complete_dot.rs | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/ra_ide/src/completion/complete_dot.rs') diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index b6fe48627..a52eb0ee4 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs @@ -216,6 +216,39 @@ mod tests { ); } + #[test] + fn test_method_completion_only_fitting_impls() { + assert_debug_snapshot!( + do_ref_completion( + r" + struct A {} + impl A { + fn the_method(&self) {} + } + impl A { + fn the_other_method(&self) {} + } + fn foo(a: A) { + a.<|> + } + ", + ), + @r###" + [ + CompletionItem { + label: "the_method()", + source_range: [243; 243), + delete: [243; 243), + insert: "the_method()$0", + kind: Method, + lookup: "the_method", + detail: "fn the_method(&self)", + }, + ] + "### + ); + } + #[test] fn test_trait_method_completion() { assert_debug_snapshot!( -- cgit v1.2.3