aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-02 23:49:09 +0100
committerPaul Daniel Faria <[email protected]>2020-06-02 23:54:00 +0100
commita9cb2933fbeddef4ed70bde77ded4f9bb185548e (patch)
tree9c501036768cc44dd687fd555d5df1e257f6b62c /crates/ra_ide/src/syntax_highlighting/tests.rs
parent2f6ab77708ae104c854712285af19516287b6906 (diff)
Add highlight support for unsafe fn calls and raw ptr deref
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index 7dc229cab..36a1aa419 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -258,3 +258,34 @@ fn main() {
258 fs::write(dst_file, &actual_html).unwrap(); 258 fs::write(dst_file, &actual_html).unwrap();
259 assert_eq_text!(expected_html, actual_html); 259 assert_eq_text!(expected_html, actual_html);
260} 260}
261
262#[test]
263fn test_unsafe_highlighting() {
264 let (analysis, file_id) = single_file(
265 r#"
266unsafe fn unsafe_fn() {}
267
268struct HasUnsafeFn;
269
270impl HasUnsafeFn {
271 unsafe fn unsafe_method(&self) {}
272}
273
274fn main() {
275 let x = &5 as *const usize;
276 unsafe {
277 unsafe_fn();
278 HasUnsafeFn.unsafe_method();
279 let y = *x;
280 let z = -x;
281 }
282}
283"#
284 .trim(),
285 );
286 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_unsafe.html");
287 let actual_html = &analysis.highlight_as_html(file_id, false).unwrap();
288 let expected_html = &read_text(&dst_file);
289 fs::write(dst_file, &actual_html).unwrap();
290 assert_eq_text!(expected_html, actual_html);
291}