aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
authorAramis Razzaghipour <[email protected]>2021-05-24 04:16:08 +0100
committerAramis Razzaghipour <[email protected]>2021-05-24 05:54:16 +0100
commitfa0d0bfb7fc402baf00ea6c6a0d87fb22157a3fb (patch)
tree16ee852de7bb86049e4be0202c82d7096523918a /crates/ide/src/syntax_highlighting/tests.rs
parentb4cddc0705665f549b7feaf9899d91cd6ced4931 (diff)
Add testing of foreign item highlighting
Diffstat (limited to 'crates/ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 9ce26e930..be4447ebb 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -10,6 +10,7 @@ use crate::{fixture, FileRange, HlTag, TextRange};
10fn test_highlighting() { 10fn test_highlighting() {
11 check_highlighting( 11 check_highlighting(
12 r#" 12 r#"
13//- /main.rs crate:main deps:foo
13use inner::{self as inner_mod}; 14use inner::{self as inner_mod};
14mod inner {} 15mod inner {}
15 16
@@ -222,6 +223,43 @@ async fn async_main() {
222 223
223unsafe trait Dangerous {} 224unsafe trait Dangerous {}
224impl Dangerous for () {} 225impl Dangerous for () {}
226
227fn use_foo_items() {
228 let bob = foo::Person {
229 name: "Bob",
230 age: foo::consts::NUMBER,
231 };
232
233 let control_flow = foo::identity(foo::ControlFlow::Continue);
234
235 if let foo::ControlFlow::Die = control_flow {
236 foo::die!();
237 }
238}
239
240
241//- /foo.rs crate:foo
242pub struct Person {
243 pub name: &'static str,
244 pub age: u8,
245}
246
247pub enum ControlFlow {
248 Continue,
249 Die,
250}
251
252pub fn identity<T>(x: T) -> T { x }
253
254pub mod consts {
255 pub const NUMBER: i64 = 92;
256}
257
258macro_rules! die {
259 () => {
260 panic!();
261 };
262}
225"# 263"#
226 .trim(), 264 .trim(),
227 expect_file!["./test_data/highlighting.html"], 265 expect_file!["./test_data/highlighting.html"],