mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
SSR: Add a couple of tests for non-recursive search
These tests already pass, however once we switch to non-recursive search, it'd be easy for these tests to not pass.
This commit is contained in:
parent
6fcaaa1201
commit
699619a65c
1 changed files with 33 additions and 0 deletions
|
@ -585,6 +585,27 @@ fn replace_within_macro_expansion() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn replace_outside_and_within_macro_expansion() {
|
||||||
|
assert_ssr_transform(
|
||||||
|
"foo($a) ==>> bar($a)",
|
||||||
|
r#"
|
||||||
|
fn foo() {} fn bar() {}
|
||||||
|
macro_rules! macro1 {
|
||||||
|
($a:expr) => {$a}
|
||||||
|
}
|
||||||
|
fn f() {foo(foo(macro1!(foo(foo(42)))))}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
fn foo() {} fn bar() {}
|
||||||
|
macro_rules! macro1 {
|
||||||
|
($a:expr) => {$a}
|
||||||
|
}
|
||||||
|
fn f() {bar(bar(macro1!(bar(bar(42)))))}
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn preserves_whitespace_within_macro_expansion() {
|
fn preserves_whitespace_within_macro_expansion() {
|
||||||
assert_ssr_transform(
|
assert_ssr_transform(
|
||||||
|
@ -631,3 +652,15 @@ fn match_failure_reasons() {
|
||||||
r#"Pattern wanted token '42' (INT_NUMBER), but code had token '43' (INT_NUMBER)"#,
|
r#"Pattern wanted token '42' (INT_NUMBER), but code had token '43' (INT_NUMBER)"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn overlapping_possible_matches() {
|
||||||
|
// There are three possible matches here, however the middle one, `foo(foo(foo(42)))` shouldn't
|
||||||
|
// match because it overlaps with the outer match. The inner match is permitted since it's is
|
||||||
|
// contained entirely within the placeholder of the outer match.
|
||||||
|
assert_matches(
|
||||||
|
"foo(foo($a))",
|
||||||
|
"fn foo() {} fn main() {foo(foo(foo(foo(42))))}",
|
||||||
|
&["foo(foo(42))", "foo(foo(foo(foo(42))))"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue