diff options
author | Phil Ellison <[email protected]> | 2019-07-28 11:45:03 +0100 |
---|---|---|
committer | Phil Ellison <[email protected]> | 2019-07-28 11:45:03 +0100 |
commit | 69244a6e18b3b53afaa0ee8073af52d93b983a86 (patch) | |
tree | fe52d2ecf2e771e1be2ed05bc9a45d48335e6bc2 /crates/ra_ide_api/src/completion/complete_snippet.rs | |
parent | 460423e66c7a8d48084813c0d592066b4bef3e85 (diff) |
Inline snapshots for all tests in complete_snippet, remove now-unused check_completion
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_snippet.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_snippet.rs | 75 |
1 files changed, 57 insertions, 18 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index d2d364b57..063b69319 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs | |||
@@ -39,39 +39,78 @@ fn ${1:feature}() { | |||
39 | 39 | ||
40 | #[cfg(test)] | 40 | #[cfg(test)] |
41 | mod tests { | 41 | mod tests { |
42 | use crate::completion::{check_completion, CompletionKind}; | 42 | use crate::completion::{do_completion, CompletionItem, CompletionKind}; |
43 | use insta::assert_debug_snapshot_matches; | ||
43 | 44 | ||
44 | fn check_snippet_completion(name: &str, code: &str) { | 45 | fn do_snippet_completion(code: &str) -> Vec<CompletionItem> { |
45 | check_completion(name, code, CompletionKind::Snippet); | 46 | do_completion(code, CompletionKind::Snippet) |
46 | } | 47 | } |
47 | 48 | ||
48 | #[test] | 49 | #[test] |
49 | fn completes_snippets_in_expressions() { | 50 | fn completes_snippets_in_expressions() { |
50 | check_snippet_completion("snippets_in_expressions", r"fn foo(x: i32) { <|> }"); | 51 | assert_debug_snapshot_matches!( |
52 | do_snippet_completion(r"fn foo(x: i32) { <|> }"), | ||
53 | @r#"[ | ||
54 | CompletionItem { | ||
55 | label: "pd", | ||
56 | source_range: [17; 17), | ||
57 | delete: [17; 17), | ||
58 | insert: "eprintln!(\"$0 = {:?}\", $0);", | ||
59 | kind: Snippet, | ||
60 | }, | ||
61 | CompletionItem { | ||
62 | label: "ppd", | ||
63 | source_range: [17; 17), | ||
64 | delete: [17; 17), | ||
65 | insert: "eprintln!(\"$0 = {:#?}\", $0);", | ||
66 | kind: Snippet, | ||
67 | }, | ||
68 | ]"# | ||
69 | ); | ||
51 | } | 70 | } |
52 | 71 | ||
53 | #[test] | 72 | #[test] |
54 | fn should_not_complete_snippets_in_path() { | 73 | fn should_not_complete_snippets_in_path() { |
55 | check_snippet_completion( | 74 | assert_debug_snapshot_matches!( |
56 | "should_not_complete_snippets_in_path", | 75 | do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"), |
57 | r"fn foo(x: i32) { ::foo<|> }", | 76 | @r#"[]"# |
58 | ); | 77 | ); |
59 | check_snippet_completion( | 78 | assert_debug_snapshot_matches!( |
60 | "should_not_complete_snippets_in_path2", | 79 | do_snippet_completion(r"fn foo(x: i32) { ::<|> }"), |
61 | r"fn foo(x: i32) { ::<|> }", | 80 | @r#"[]"# |
62 | ); | 81 | ); |
63 | } | 82 | } |
64 | 83 | ||
65 | #[test] | 84 | #[test] |
66 | fn completes_snippets_in_items() { | 85 | fn completes_snippets_in_items() { |
67 | check_snippet_completion( | 86 | assert_debug_snapshot_matches!( |
68 | "snippets_in_items", | 87 | do_snippet_completion( |
69 | r" | 88 | r" |
70 | #[cfg(test)] | 89 | #[cfg(test)] |
71 | mod tests { | 90 | mod tests { |
72 | <|> | 91 | <|> |
73 | } | 92 | } |
74 | ", | 93 | " |
94 | ), | ||
95 | @r###" | ||
96 | ⋮[ | ||
97 | ⋮ CompletionItem { | ||
98 | ⋮ label: "Test function", | ||
99 | ⋮ source_range: [78; 78), | ||
100 | ⋮ delete: [78; 78), | ||
101 | ⋮ insert: "#[test]\nfn ${1:feature}() {\n $0\n}", | ||
102 | ⋮ kind: Snippet, | ||
103 | ⋮ lookup: "tfn", | ||
104 | ⋮ }, | ||
105 | ⋮ CompletionItem { | ||
106 | ⋮ label: "pub(crate)", | ||
107 | ⋮ source_range: [78; 78), | ||
108 | ⋮ delete: [78; 78), | ||
109 | ⋮ insert: "pub(crate) $0", | ||
110 | ⋮ kind: Snippet, | ||
111 | ⋮ }, | ||
112 | ⋮] | ||
113 | "### | ||
75 | ); | 114 | ); |
76 | } | 115 | } |
77 | } | 116 | } |