aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
authorChetan Khilosiya <[email protected]>2021-03-30 20:00:01 +0100
committerChetan Khilosiya <[email protected]>2021-03-30 20:01:15 +0100
commitd7dcd41801b319f64f3ca2ed22735ab70092e491 (patch)
tree7e74b7a6504ce9d55cfe123cdc92f5b1d6532ef2 /crates/ide/src/syntax_highlighting/tests.rs
parent56f624532aec04a3a1cccf48ff62c490f52826a0 (diff)
8024: Added test case for highlighting trait items.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 369ae0972..7b3b5caf9 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -659,6 +659,43 @@ fn foo() {
659 ); 659 );
660} 660}
661 661
662#[test]
663fn test_highlight_trait_items() {
664 check_highlighting(
665 r#"
666struct Cat;
667
668trait Animal {
669 const SOUND: &'static str;
670
671 fn make_sound(&self) {
672 println!("{}", Self::SOUND);
673 }
674}
675
676impl Animal for Cat {
677 const SOUND: &'static str = "Meow!";
678}
679
680impl Cat {
681 const SPEED: u32 = 2;
682
683 fn run() {}
684}
685
686fn main() {
687 let cat = Cat;
688 cat.make_sound();
689 let _sound = Cat::SOUND;
690 let _speed = Cat::SPEED;
691 Cat::run();
692}
693"#,
694 expect_file!["./test_data/highlight_trait_items.html"],
695 false,
696 );
697}
698
662/// Highlights the code given by the `ra_fixture` argument, renders the 699/// Highlights the code given by the `ra_fixture` argument, renders the
663/// result as HTML, and compares it with the HTML file given as `snapshot`. 700/// result as HTML, and compares it with the HTML file given as `snapshot`.
664/// Note that the `snapshot` file is overwritten by the rendered HTML. 701/// Note that the `snapshot` file is overwritten by the rendered HTML.