From ca42f621c61007263c0c7d6a068119aefb88ac11 Mon Sep 17 00:00:00 2001 From: funkill2 Date: Sun, 7 Jul 2019 13:52:16 +0300 Subject: inline snapshot in complete_postfix --- .../ra_ide_api/src/completion/complete_postfix.rs | 82 +++++++++++++++++++--- ...mpletion_works_for_trivial_path_expression.snap | 64 ----------------- 2 files changed, 71 insertions(+), 75 deletions(-) delete mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs index 7042d8bff..a25e517f5 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs @@ -51,22 +51,82 @@ pub(super) fn complete_postfix(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_snippet_completion(test_name: &str, code: &str) { - check_completion(test_name, code, CompletionKind::Postfix); + fn do_postfix_completion(code: &str) -> Vec { + do_completion(code, CompletionKind::Postfix) } #[test] fn postfix_completion_works_for_trivial_path_expression() { - check_snippet_completion( - "postfix_completion_works_for_trivial_path_expression", - r#" - fn main() { - let bar = "a"; - bar.<|> - } - "#, + assert_debug_snapshot_matches!( + do_postfix_completion( + r#" + fn main() { + let bar = "a"; + bar.<|> + } + "#, + ), + @r###"[ + CompletionItem { + label: "box", + source_range: [88; 88), + delete: [84; 88), + insert: "Box::new(bar)", + detail: "Box::new(expr)", + }, + CompletionItem { + label: "dbg", + source_range: [88; 88), + delete: [84; 88), + insert: "dbg!(bar)", + detail: "dbg!(expr)", + }, + CompletionItem { + label: "if", + source_range: [88; 88), + delete: [84; 88), + insert: "if bar {$0}", + detail: "if expr {}", + }, + CompletionItem { + label: "match", + source_range: [88; 88), + delete: [84; 88), + insert: "match bar {\n ${1:_} => {$0\\},\n}", + detail: "match expr {}", + }, + CompletionItem { + label: "not", + source_range: [88; 88), + delete: [84; 88), + insert: "!bar", + detail: "!expr", + }, + CompletionItem { + label: "ref", + source_range: [88; 88), + delete: [84; 88), + insert: "&bar", + detail: "&expr", + }, + CompletionItem { + label: "refm", + source_range: [88; 88), + delete: [84; 88), + insert: "&mut bar", + detail: "&mut expr", + }, + CompletionItem { + label: "while", + source_range: [88; 88), + delete: [84; 88), + insert: "while bar {\n$0\n}", + detail: "while expr {}", + }, +]"### ); } } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap deleted file mode 100644 index c1a40b7b4..000000000 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -created: "2019-06-23T13:01:08.775536006Z" -creator: insta@0.8.1 -source: crates/ra_ide_api/src/completion/completion_item.rs -expression: kind_completions ---- -[ - CompletionItem { - label: "box", - source_range: [76; 76), - delete: [72; 76), - insert: "Box::new(bar)", - detail: "Box::new(expr)", - }, - CompletionItem { - label: "dbg", - source_range: [76; 76), - delete: [72; 76), - insert: "dbg!(bar)", - detail: "dbg!(expr)", - }, - CompletionItem { - label: "if", - source_range: [76; 76), - delete: [72; 76), - insert: "if bar {$0}", - detail: "if expr {}", - }, - CompletionItem { - label: "match", - source_range: [76; 76), - delete: [72; 76), - insert: "match bar {\n ${1:_} => {$0\\},\n}", - detail: "match expr {}", - }, - CompletionItem { - label: "not", - source_range: [76; 76), - delete: [72; 76), - insert: "!bar", - detail: "!expr", - }, - CompletionItem { - label: "ref", - source_range: [76; 76), - delete: [72; 76), - insert: "&bar", - detail: "&expr", - }, - CompletionItem { - label: "refm", - source_range: [76; 76), - delete: [72; 76), - insert: "&mut bar", - detail: "&mut expr", - }, - CompletionItem { - label: "while", - source_range: [76; 76), - delete: [72; 76), - insert: "while bar {\n$0\n}", - detail: "while expr {}", - }, -] -- cgit v1.2.3