From fa0d0bfb7fc402baf00ea6c6a0d87fb22157a3fb Mon Sep 17 00:00:00 2001 From: Aramis Razzaghipour Date: Mon, 24 May 2021 13:16:08 +1000 Subject: Add testing of foreign item highlighting --- .../test_data/highlighting.html | 18 +++++++++- crates/ide/src/syntax_highlighting/tests.rs | 38 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index 878431b56..e65dd3ff9 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -248,4 +248,20 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } unsafe trait Dangerous {} -impl Dangerous for () {} \ No newline at end of file +impl Dangerous for () {} + +fn use_foo_items() { + let bob = foo::Person { + name: "Bob", + age: foo::consts::NUMBER, + }; + + let control_flow = foo::identity(foo::ControlFlow::Continue); + + if let foo::ControlFlow::Die = control_flow { + foo::die!(); + } +} + + + \ No newline at end of file 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}; fn test_highlighting() { check_highlighting( r#" +//- /main.rs crate:main deps:foo use inner::{self as inner_mod}; mod inner {} @@ -222,6 +223,43 @@ async fn async_main() { unsafe trait Dangerous {} impl Dangerous for () {} + +fn use_foo_items() { + let bob = foo::Person { + name: "Bob", + age: foo::consts::NUMBER, + }; + + let control_flow = foo::identity(foo::ControlFlow::Continue); + + if let foo::ControlFlow::Die = control_flow { + foo::die!(); + } +} + + +//- /foo.rs crate:foo +pub struct Person { + pub name: &'static str, + pub age: u8, +} + +pub enum ControlFlow { + Continue, + Die, +} + +pub fn identity(x: T) -> T { x } + +pub mod consts { + pub const NUMBER: i64 = 92; +} + +macro_rules! die { + () => { + panic!(); + }; +} "# .trim(), expect_file!["./test_data/highlighting.html"], -- cgit v1.2.3