aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorKevin DeLorey <[email protected]>2020-02-11 03:02:51 +0000
committerKevin DeLorey <[email protected]>2020-02-11 03:02:51 +0000
commit785723e0d942bba935fb2de6fb451d57a2c06b1a (patch)
tree34ce14d4a467e7854cb81d1aaaa8487d386c6932 /crates
parent52c4324e31361d062ff111835abaec2c4eff0db4 (diff)
Added tests to test associated types and consts.
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs78
1 files changed, 78 insertions, 0 deletions
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 {
283 ] 283 ]
284 "###); 284 "###);
285 } 285 }
286
287 #[test]
288 fn associated_type() {
289 let completions = complete(
290 r"
291 trait Test {
292 type SomeType;
293 }
294
295 impl Test for () {
296 <|>
297 }
298 ",
299 );
300 assert_debug_snapshot!(completions, @r###"
301 [
302 CompletionItem {
303 label: "type SomeType = ",
304 source_range: [119; 119),
305 delete: [119; 119),
306 insert: "type SomeType = ",
307 kind: TypeAlias,
308 },
309 ]
310 "###);
311 }
312
313 #[test]
314 fn associated_const() {
315 let completions = complete(
316 r"
317 trait Test {
318 const SOME_CONST: u16;
319 }
320
321 impl Test for () {
322 <|>
323 }
324 ",
325 );
326 assert_debug_snapshot!(completions, @r###"
327 [
328 CompletionItem {
329 label: "const SOME_CONST: u16 = ",
330 source_range: [127; 127),
331 delete: [127; 127),
332 insert: "const SOME_CONST: u16 = ",
333 kind: Const,
334 },
335 ]
336 "###);
337 }
338
339 #[test]
340 fn associated_const_with_default() {
341 let completions = complete(
342 r"
343 trait Test {
344 const SOME_CONST: u16 = 42;
345 }
346
347 impl Test for () {
348 <|>
349 }
350 ",
351 );
352 assert_debug_snapshot!(completions, @r###"
353 [
354 CompletionItem {
355 label: "const SOME_CONST: u16 = ",
356 source_range: [132; 132),
357 delete: [132; 132),
358 insert: "const SOME_CONST: u16 = ",
359 kind: Const,
360 },
361 ]
362 "###);
363 }
286} 364}