Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/tests.rs')
| -rw-r--r-- | crates/ide/src/syntax_highlighting/tests.rs | 95 |
1 files changed, 91 insertions, 4 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 8198701d68..b7510e3aba 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -1,13 +1,13 @@ use std::time::Instant; use expect_test::{ExpectFile, expect_file}; -use ide_db::SymbolKind; +use ide_db::{MiniCore, SymbolKind}; use span::Edition; use test_utils::{AssertLinear, bench, bench_fixture, skip_slow_tests}; use crate::{FileRange, HighlightConfig, HlTag, TextRange, fixture}; -const HL_CONFIG: HighlightConfig = HighlightConfig { +const HL_CONFIG: HighlightConfig<'_> = HighlightConfig { strings: true, comments: true, punctuation: true, @@ -17,6 +17,7 @@ const HL_CONFIG: HighlightConfig = HighlightConfig { inject_doc_comment: true, macro_bang: true, syntactic_name_ref_highlighting: false, + minicore: MiniCore::default(), }; #[test] @@ -1017,6 +1018,35 @@ impl t for foo { } #[test] +fn test_injection_2() { + check_highlighting( + r##" +fn fixture(#[rust_analyzer::rust_fixture] ra_fixture: &str) {} + +fn main() { + fixture(r#" +@@- /main.rs crate:main deps:other_crate +fn test() { + let x = other_crate::foo::S::thing(); + x; +} //^ i128 + +@@- /lib.rs crate:other_crate +pub mod foo { + pub struct S; + impl S { + pub fn thing() -> i128 { 0 } + } +} + "#); +} +"##, + expect_file!["./test_data/highlight_injection_2.html"], + false, + ); +} + +#[test] fn test_injection() { check_highlighting( r##" @@ -1024,7 +1054,8 @@ fn fixture(#[rust_analyzer::rust_fixture] ra_fixture: &str) {} fn main() { fixture(r#" -trait Foo { +@@- minicore: sized +trait Foo: Sized { fn foo() { println!("2 + 2 = {}", 4); } @@ -1223,7 +1254,7 @@ fn foo(x: &fn(&dyn Trait)) {} /// Note that the `snapshot` file is overwritten by the rendered HTML. fn check_highlighting_with_config( #[rust_analyzer::rust_fixture] ra_fixture: &str, - config: HighlightConfig, + config: HighlightConfig<'_>, expect: ExpectFile, rainbow: bool, ) { @@ -1466,3 +1497,59 @@ fn main() { false, ); } + +#[test] +fn regression_20952() { + check_highlighting( + r#" +//- minicore: fmt +fn main() { + format_args!("{} {}, {} (подозрение на спам: {:.2}%)"б); +} +"#, + expect_file!["./test_data/regression_20952.html"], + false, + ); +} + +#[test] +fn test_deprecated_highlighting() { + check_highlighting( + r#" +//- /foo.rs crate:foo deps:bar +#![deprecated] +use crate as _; +extern crate bar; +#[deprecated] +macro_rules! macro_ { + () => {}; +} +#[deprecated] +mod mod_ {} +#[deprecated] +fn func() {} +#[deprecated] +struct Struct { + #[deprecated] + field: u32 +} +#[deprecated] +enum Enum { + #[deprecated] + Variant +} +#[deprecated] +const CONST: () = (); +#[deprecated] +trait Trait {} +#[deprecated] +type Alias = (); +#[deprecated] +static STATIC: () = (); +//- /bar.rs crate:bar +#![deprecated] + "#, + expect_file!["./test_data/highlight_deprecated.html"], + false, + ); +} |