diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_attributes.html b/crates/ide/src/syntax_highlighting/test_data/highlight_attributes.html new file mode 100644 index 0000000000..9fe2b50cde --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_attributes.html @@ -0,0 +1,57 @@ + + +
#[allow(dead_code)]
+#[rustfmt::skip]
+#[proc_macros::identity]
+#[derive(Copy)]
+/// This is a doc comment
+// This is a normal comment
+/// This is a doc comment
+#[derive(Copy)]
+// This is another normal comment
+/// This is another doc comment
+// This is another normal comment
+#[derive(Copy)]
+// The reason for these being here is to test AttrIds
+struct Foo;
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlight_general.html similarity index 100% rename from crates/ide/src/syntax_highlighting/test_data/highlighting.html rename to crates/ide/src/syntax_highlighting/test_data/highlight_general.html diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html index 1713306dae..023e791f8b 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html @@ -45,10 +45,17 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fn main() { fixture(r#" - trait Foo { - fn foo() { - println!("2 + 2 = {}", 4); - } - }"# +trait Foo { + fn foo() { + println!("2 + 2 = {}", 4); + } +}"# + ); + fixture(r" +fn foo() { + foo($0{ + 92 + }$0) +}" ); } \ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html b/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html new file mode 100644 index 0000000000..c3f71d443f --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_macros.html @@ -0,0 +1,88 @@ + + +
proc_macros::mirror! {
+    {
+        ,i32 :x pub
+        ,i32 :y pub
+    } Foo struct
+}
+macro_rules! def_fn {
+    ($($tt:tt)*) => {$($tt)*}
+}
+
+def_fn! {
+    fn bar() -> u32 {
+        100
+    }
+}
+
+macro_rules! dont_color_me_braces {
+    () => {0}
+}
+
+macro_rules! noop {
+    ($expr:expr) => {
+        $expr
+    }
+}
+
+macro_rules! keyword_frag {
+    ($type:ty) => ($type)
+}
+
+macro with_args($i:ident) {
+    $i
+}
+
+macro without_args {
+    ($i:ident) => {
+        $i
+    }
+}
+
+fn main() {
+    println!("Hello, {}!", 92);
+    dont_color_me_braces!();
+    noop!(noop!(1));
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlight_rainbow.html similarity index 100% rename from crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html rename to crates/ide/src/syntax_highlighting/test_data/highlight_rainbow.html diff --git a/crates/ide/src/syntax_highlighting/test_data/injection.html b/crates/ide/src/syntax_highlighting/test_data/injection.html deleted file mode 100644 index ce4e22379e..0000000000 --- a/crates/ide/src/syntax_highlighting/test_data/injection.html +++ /dev/null @@ -1,52 +0,0 @@ - - -
fn f(ra_fixture: &str) {}
-fn main() {
-    f(r"
-fn foo() {
-    foo($0{
-        92
-    }$0)
-}");
-}
\ 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 f114840373..ec50fde356 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -27,7 +27,7 @@ fn attributes() { // The reason for these being here is to test AttrIds struct Foo; "#, - expect_file!["./test_data/attributes.html"], + expect_file!["./test_data/highlight_attributes.html"], false, ); } @@ -82,11 +82,13 @@ fn main() { noop!(noop!(1)); } "#, - expect_file!["./test_data/macros.html"], + expect_file!["./test_data/highlight_macros.html"], false, ); } +/// If what you want to test feels like a specific entity consider making a new test instead, +/// this test fixture here in fact should shrink instead of grow ideally. #[test] fn test_highlighting() { check_highlighting( @@ -305,7 +307,7 @@ macro_rules! die { }; } "#, - expect_file!["./test_data/highlighting.html"], + expect_file!["./test_data/highlight_general.html"], false, ); } @@ -762,17 +764,26 @@ impl t for foo { fn test_injection() { check_highlighting( r##" -fn f(ra_fixture: &str) {} +fn fixture(ra_fixture: &str) {} + fn main() { - f(r" + fixture(r#" +trait Foo { + fn foo() { + println!("2 + 2 = {}", 4); + } +}"# + ); + fixture(r" fn foo() { foo(\$0{ 92 }\$0) -}"); +}" + ); } "##, - expect_file!["./test_data/injection.html"], + expect_file!["./test_data/highlight_injection.html"], false, ); } @@ -794,7 +805,7 @@ fn bar() { let mut hello = "hello"; } "#, - expect_file!["./test_data/rainbow_highlighting.html"], + expect_file!["./test_data/highlight_rainbow.html"], true, ); } @@ -819,26 +830,6 @@ struct Foo { assert_eq!(&highlights[0].highlight.to_string(), "field.declaration.public"); } -#[test] -fn test_flattening() { - check_highlighting( - r##" -fn fixture(ra_fixture: &str) {} - -fn main() { - fixture(r#" - trait Foo { - fn foo() { - println!("2 + 2 = {}", 4); - } - }"# - ); -}"##, - expect_file!["./test_data/highlight_injection.html"], - false, - ); -} - #[test] fn ranges_sorted() { let (analysis, file_id) = fixture::file(