diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-03 22:16:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-03 22:16:38 +0100 |
commit | f6bff05f2adfabae41ce9d2c5dabc2fb35ad21de (patch) | |
tree | 802521f357257f38db18738059457a77387ea70c /crates/ra_ide/src/completion/test_utils.rs | |
parent | a095cdb87912e0174341121542af2d4a01d7d8cd (diff) | |
parent | 9f9b38bdb47f6301fc01287fbe8dc1256c44fe08 (diff) |
Merge #5214
5214: Cleanup presentation tests r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/test_utils.rs')
-rw-r--r-- | crates/ra_ide/src/completion/test_utils.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs index 9c036eac7..f25190241 100644 --- a/crates/ra_ide/src/completion/test_utils.rs +++ b/crates/ra_ide/src/completion/test_utils.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use hir::Semantics; | 3 | use hir::Semantics; |
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | use ra_syntax::{AstNode, NodeOrToken, SyntaxElement}; | 5 | use ra_syntax::{AstNode, NodeOrToken, SyntaxElement}; |
6 | use stdx::format_to; | 6 | use stdx::{format_to, trim_indent}; |
7 | use test_utils::assert_eq_text; | 7 | use test_utils::assert_eq_text; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
@@ -57,14 +57,18 @@ pub(crate) fn completion_list_with_options( | |||
57 | } | 57 | } |
58 | 58 | ||
59 | pub(crate) fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | 59 | pub(crate) fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) { |
60 | let ra_fixture_after = trim_indent(ra_fixture_after); | ||
60 | let (analysis, position) = analysis_and_position(ra_fixture_before); | 61 | let (analysis, position) = analysis_and_position(ra_fixture_before); |
61 | let completions: Vec<CompletionItem> = | 62 | let completions: Vec<CompletionItem> = |
62 | analysis.completions(&CompletionConfig::default(), position).unwrap().unwrap().into(); | 63 | analysis.completions(&CompletionConfig::default(), position).unwrap().unwrap().into(); |
63 | let (completion,) = | 64 | let (completion,) = completions |
64 | completions.into_iter().filter(|it| it.label() == what).collect_tuple().unwrap(); | 65 | .iter() |
66 | .filter(|it| it.lookup() == what) | ||
67 | .collect_tuple() | ||
68 | .unwrap_or_else(|| panic!("can't find {:?} completion in {:#?}", what, completions)); | ||
65 | let mut actual = analysis.file_text(position.file_id).unwrap().to_string(); | 69 | let mut actual = analysis.file_text(position.file_id).unwrap().to_string(); |
66 | completion.text_edit().apply(&mut actual); | 70 | completion.text_edit().apply(&mut actual); |
67 | assert_eq_text!(ra_fixture_after, &actual) | 71 | assert_eq_text!(&ra_fixture_after, &actual) |
68 | } | 72 | } |
69 | 73 | ||
70 | pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -> bool) { | 74 | pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -> bool) { |