diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index b7fad9719..39cd74ac3 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -370,3 +370,31 @@ fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { | |||
370 | fs::write(dst_file, &actual_html).unwrap(); | 370 | fs::write(dst_file, &actual_html).unwrap(); |
371 | assert_eq_text!(expected_html, actual_html); | 371 | assert_eq_text!(expected_html, actual_html); |
372 | } | 372 | } |
373 | |||
374 | #[test] | ||
375 | fn test_unsafe_highlighting() { | ||
376 | let (analysis, file_id) = single_file( | ||
377 | r#" | ||
378 | unsafe fn unsafe_fn() {} | ||
379 | |||
380 | struct HasUnsafeFn; | ||
381 | |||
382 | impl HasUnsafeFn { | ||
383 | unsafe fn unsafe_method(&self) {} | ||
384 | } | ||
385 | |||
386 | fn main() { | ||
387 | unsafe { | ||
388 | unsafe_fn(); | ||
389 | HasUnsafeFn.unsafe_method(); | ||
390 | } | ||
391 | } | ||
392 | "# | ||
393 | .trim(), | ||
394 | ); | ||
395 | let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_unsafe.html"); | ||
396 | let actual_html = &analysis.highlight_as_html(file_id, false).unwrap(); | ||
397 | let expected_html = &read_text(&dst_file); | ||
398 | fs::write(dst_file, &actual_html).unwrap(); | ||
399 | assert_eq_text!(expected_html, actual_html); | ||
400 | } | ||