diff options
-rw-r--r-- | crates/ra_ssr/src/tests.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index d7e6d817a..7a3141be8 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs | |||
@@ -209,6 +209,11 @@ fn assert_ssr_transform(rule: &str, input: &str, result: &str) { | |||
209 | assert_ssr_transforms(&[rule], input, result); | 209 | assert_ssr_transforms(&[rule], input, result); |
210 | } | 210 | } |
211 | 211 | ||
212 | fn normalize_code(code: &str) -> String { | ||
213 | let (db, file_id) = single_file(code); | ||
214 | db.file_text(file_id).to_string() | ||
215 | } | ||
216 | |||
212 | fn assert_ssr_transforms(rules: &[&str], input: &str, result: &str) { | 217 | fn assert_ssr_transforms(rules: &[&str], input: &str, result: &str) { |
213 | let (db, file_id) = single_file(input); | 218 | let (db, file_id) = single_file(input); |
214 | let mut match_finder = MatchFinder::new(&db); | 219 | let mut match_finder = MatchFinder::new(&db); |
@@ -217,8 +222,13 @@ fn assert_ssr_transforms(rules: &[&str], input: &str, result: &str) { | |||
217 | match_finder.add_rule(rule); | 222 | match_finder.add_rule(rule); |
218 | } | 223 | } |
219 | if let Some(edits) = match_finder.edits_for_file(file_id) { | 224 | if let Some(edits) = match_finder.edits_for_file(file_id) { |
220 | let mut after = input.to_string(); | 225 | // Note, db.file_text is not necessarily the same as `input`, since fixture parsing alters |
226 | // stuff. | ||
227 | let mut after = db.file_text(file_id).to_string(); | ||
221 | edits.apply(&mut after); | 228 | edits.apply(&mut after); |
229 | // Likewise, we need to make sure that whatever transformations fixture parsing applies, | ||
230 | // also get appplied to our expected result. | ||
231 | let result = normalize_code(result); | ||
222 | assert_eq!(after, result); | 232 | assert_eq!(after, result); |
223 | } else { | 233 | } else { |
224 | panic!("No edits were made"); | 234 | panic!("No edits were made"); |