aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index 7f442bd0f..110887c2a 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -134,16 +134,25 @@ fn test_ranges() {
134 134
135#[test] 135#[test]
136fn test_flattening() { 136fn test_flattening() {
137 let (analysis, file_id) = single_file(r#"#[cfg(feature = "foo")]"#); 137 let (analysis, file_id) = single_file(
138 138 r##"
139 let highlights = analysis.highlight(file_id).unwrap(); 139fn fixture(ra_fixture: &str) {}
140 140
141 // The source code snippet contains 2 nested highlights: 141fn main() {
142 // 1) Attribute spanning the whole string 142 fixture(r#"
143 // 2) The string "foo" 143 trait Foo {
144 // The resulting flattening splits the attribute range: 144 fn foo() {
145 assert_eq!(highlights.len(), 3); 145 println!("2 + 2 = {}", 4);
146 assert_eq!(&highlights[0].highlight.to_string(), "attribute"); 146 }
147 assert_eq!(&highlights[1].highlight.to_string(), "string_literal"); 147 }"#
148 assert_eq!(&highlights[2].highlight.to_string(), "attribute"); 148 );
149}"##
150 .trim(),
151 );
152
153 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_injection.html");
154 let actual_html = &analysis.highlight_as_html(file_id, false).unwrap();
155 let expected_html = &read_text(&dst_file);
156 fs::write(dst_file, &actual_html).unwrap();
157 assert_eq_text!(expected_html, actual_html);
149} 158}