From 1b19c1c8f218d0c23e78a14b80845bf7c2cfd32c Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Wed, 10 Apr 2019 13:22:50 +0300 Subject: Use inline snapshots in complete_fn_param --- .../ra_ide_api/src/completion/complete_fn_param.rs | 85 +++++++++++++++------- ...mpletion_item__param_completion_last_param.snap | 15 ---- ...ompletion_item__param_completion_nth_param.snap | 15 ---- ...pletion_item__param_completion_trait_param.snap | 15 ---- 4 files changed, 58 insertions(+), 72 deletions(-) delete mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap delete mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap delete mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs index f87ccdeb9..85ef62f52 100644 --- a/crates/ra_ide_api/src/completion/complete_fn_param.rs +++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs @@ -54,48 +54,79 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) #[cfg(test)] mod tests { - use crate::completion::{check_completion, CompletionKind}; + use crate::completion::{do_completion, CompletionItem, CompletionKind}; + use insta::assert_debug_snapshot_matches; - fn check_magic_completion(name: &str, code: &str) { - check_completion(name, code, CompletionKind::Magic); + fn do_magic_completion(code: &str) -> Vec { + do_completion(code, CompletionKind::Magic) } #[test] fn test_param_completion_last_param() { - check_magic_completion( - "param_completion_last_param", - r" - fn foo(file_id: FileId) {} - fn bar(file_id: FileId) {} - fn baz(file<|>) {} - ", + assert_debug_snapshot_matches!( + do_magic_completion( + r" + fn foo(file_id: FileId) {} + fn bar(file_id: FileId) {} + fn baz(file<|>) {} + ", + ), + @r###"[ + CompletionItem { + label: "file_id: FileId", + source_range: [110; 114), + delete: [110; 114), + insert: "file_id: FileId", + lookup: "file_id" + } +]"### ); } #[test] fn test_param_completion_nth_param() { - check_magic_completion( - "param_completion_nth_param", - r" - fn foo(file_id: FileId) {} - fn bar(file_id: FileId) {} - fn baz(file<|>, x: i32) {} - ", + assert_debug_snapshot_matches!( + do_magic_completion( + r" + fn foo(file_id: FileId) {} + fn bar(file_id: FileId) {} + fn baz(file<|>, x: i32) {} + ", + ), + @r###"[ + CompletionItem { + label: "file_id: FileId", + source_range: [110; 114), + delete: [110; 114), + insert: "file_id: FileId", + lookup: "file_id" + } +]"### ); } #[test] fn test_param_completion_trait_param() { - check_magic_completion( - "param_completion_trait_param", - r" - pub(crate) trait SourceRoot { - pub fn contains(&self, file_id: FileId) -> bool; - pub fn module_map(&self) -> &ModuleMap; - pub fn lines(&self, file_id: FileId) -> &LineIndex; - pub fn syntax(&self, file<|>) - } - ", + assert_debug_snapshot_matches!( + do_magic_completion( + r" + pub(crate) trait SourceRoot { + pub fn contains(&self, file_id: FileId) -> bool; + pub fn module_map(&self) -> &ModuleMap; + pub fn lines(&self, file_id: FileId) -> &LineIndex; + pub fn syntax(&self, file<|>) + } + ", + ), + @r###"[ + CompletionItem { + label: "file_id: FileId", + source_range: [289; 293), + delete: [289; 293), + insert: "file_id: FileId", + lookup: "file_id" + } +]"### ); } } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap deleted file mode 100644 index cab77f5a2..000000000 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -created: "2019-02-18T09:22:23.949634602Z" -creator: insta@0.6.2 -source: crates/ra_ide_api/src/completion/completion_item.rs -expression: kind_completions ---- -[ - CompletionItem { - label: "file_id: FileId", - source_range: [98; 102), - delete: [98; 102), - insert: "file_id: FileId", - lookup: "file_id" - } -] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap deleted file mode 100644 index 8fbee160c..000000000 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -created: "2019-02-18T09:22:23.949634355Z" -creator: insta@0.6.2 -source: crates/ra_ide_api/src/completion/completion_item.rs -expression: kind_completions ---- -[ - CompletionItem { - label: "file_id: FileId", - source_range: [98; 102), - delete: [98; 102), - insert: "file_id: FileId", - lookup: "file_id" - } -] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap deleted file mode 100644 index 76eeadb6d..000000000 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -created: "2019-02-18T09:22:23.974417169Z" -creator: insta@0.6.2 -source: crates/ra_ide_api/src/completion/completion_item.rs -expression: kind_completions ---- -[ - CompletionItem { - label: "file_id: FileId", - source_range: [269; 273), - delete: [269; 273), - insert: "file_id: FileId", - lookup: "file_id" - } -] -- cgit v1.2.3