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 --- crates/ide/src/syntax_highlighting/tests.rs | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crates/ide/src/syntax_highlighting/tests.rs') 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