From 785723e0d942bba935fb2de6fb451d57a2c06b1a Mon Sep 17 00:00:00 2001 From: Kevin DeLorey <2295721+kdelorey@users.noreply.github.com> Date: Mon, 10 Feb 2020 21:02:51 -0600 Subject: Added tests to test associated types and consts. --- .../ra_ide/src/completion/complete_trait_impl.rs | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'crates') diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index eb12b7d28..c0e83b124 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -283,4 +283,82 @@ mod tests { ] "###); } + + #[test] + fn associated_type() { + let completions = complete( + r" + trait Test { + type SomeType; + } + + impl Test for () { + <|> + } + ", + ); + assert_debug_snapshot!(completions, @r###" + [ + CompletionItem { + label: "type SomeType = ", + source_range: [119; 119), + delete: [119; 119), + insert: "type SomeType = ", + kind: TypeAlias, + }, + ] + "###); + } + + #[test] + fn associated_const() { + let completions = complete( + r" + trait Test { + const SOME_CONST: u16; + } + + impl Test for () { + <|> + } + ", + ); + assert_debug_snapshot!(completions, @r###" + [ + CompletionItem { + label: "const SOME_CONST: u16 = ", + source_range: [127; 127), + delete: [127; 127), + insert: "const SOME_CONST: u16 = ", + kind: Const, + }, + ] + "###); + } + + #[test] + fn associated_const_with_default() { + let completions = complete( + r" + trait Test { + const SOME_CONST: u16 = 42; + } + + impl Test for () { + <|> + } + ", + ); + assert_debug_snapshot!(completions, @r###" + [ + CompletionItem { + label: "const SOME_CONST: u16 = ", + source_range: [132; 132), + delete: [132; 132), + insert: "const SOME_CONST: u16 = ", + kind: Const, + }, + ] + "###); + } } -- cgit v1.2.3