aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMikhail Rakhmanov <[email protected]>2020-06-12 11:15:53 +0100
committerMikhail Rakhmanov <[email protected]>2020-06-12 11:15:53 +0100
commitf123539ad20c6c082a5e6aa69816429c3f73935a (patch)
tree6097995c85db7b77f6043a46c30b3353f17360e8 /crates
parent4c92f2d19089c28c59aec27ff7e1b620eeef6f8e (diff)
More assert refactoring
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/completion/complete_keyword.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs
index 7eddf76b9..2e76f8592 100644
--- a/crates/ra_ide/src/completion/complete_keyword.rs
+++ b/crates/ra_ide/src/completion/complete_keyword.rs
@@ -118,7 +118,7 @@ mod tests {
118 }, 118 },
119 CompletionItemKind, 119 CompletionItemKind,
120 }; 120 };
121 use insta::assert_debug_snapshot; 121 use insta::{assert_snapshot, assert_debug_snapshot};
122 use rustc_hash::FxHashSet; 122 use rustc_hash::FxHashSet;
123 123
124 fn do_keyword_completion(code: &str) -> Vec<CompletionItem> { 124 fn do_keyword_completion(code: &str) -> Vec<CompletionItem> {
@@ -128,11 +128,12 @@ mod tests {
128 fn assert_completion_keyword(code: &str, keywords: &[(&str, &str)]) { 128 fn assert_completion_keyword(code: &str, keywords: &[(&str, &str)]) {
129 let (position, completion_items) = 129 let (position, completion_items) =
130 do_completion_with_position(code, CompletionKind::Keyword); 130 do_completion_with_position(code, CompletionKind::Keyword);
131 let mut set = FxHashSet::<(String, String)>::default(); 131 let mut expected_keywords = FxHashSet::<(String, String)>::default();
132 for (key, value) in keywords { 132 for (key, value) in keywords {
133 set.insert(((*key).to_string(), (*value).to_string())); 133 expected_keywords.insert(((*key).to_string(), (*value).to_string()));
134 } 134 }
135 135 let mut returned_keywords = FxHashSet::<(String, String)>::default();
136
136 for item in completion_items { 137 for item in completion_items {
137 assert!(item.text_edit().len() == 1); 138 assert!(item.text_edit().len() == 1);
138 assert!(item.kind() == Some(CompletionItemKind::Keyword)); 139 assert!(item.kind() == Some(CompletionItemKind::Keyword));
@@ -140,10 +141,10 @@ mod tests {
140 assert!(atom.delete.start() == position.offset); 141 assert!(atom.delete.start() == position.offset);
141 assert!(atom.delete.end() == position.offset); 142 assert!(atom.delete.end() == position.offset);
142 let pair = (item.label().to_string(), atom.insert); 143 let pair = (item.label().to_string(), atom.insert);
143 assert!(set.contains(&pair)); 144 returned_keywords.insert(pair);
144 set.remove(&pair);
145 } 145 }
146 assert!(set.is_empty()); 146 let assert_failed_message = format!("Expected keywords: {:#?}\nReceived keywords: {:#?}", expected_keywords, returned_keywords);
147 debug_assert!(returned_keywords == expected_keywords, assert_failed_message);
147 } 148 }
148 149
149 #[test] 150 #[test]