diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 98c030791..7f442bd0f 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -131,3 +131,19 @@ fn test_ranges() { | |||
131 | 131 | ||
132 | assert_eq!(&highlights[0].highlight.to_string(), "field.declaration"); | 132 | assert_eq!(&highlights[0].highlight.to_string(), "field.declaration"); |
133 | } | 133 | } |
134 | |||
135 | #[test] | ||
136 | fn test_flattening() { | ||
137 | let (analysis, file_id) = single_file(r#"#[cfg(feature = "foo")]"#); | ||
138 | |||
139 | let highlights = analysis.highlight(file_id).unwrap(); | ||
140 | |||
141 | // The source code snippet contains 2 nested highlights: | ||
142 | // 1) Attribute spanning the whole string | ||
143 | // 2) The string "foo" | ||
144 | // The resulting flattening splits the attribute range: | ||
145 | assert_eq!(highlights.len(), 3); | ||
146 | assert_eq!(&highlights[0].highlight.to_string(), "attribute"); | ||
147 | assert_eq!(&highlights[1].highlight.to_string(), "string_literal"); | ||
148 | assert_eq!(&highlights[2].highlight.to_string(), "attribute"); | ||
149 | } | ||