aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/tests.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-27 09:06:18 +0100
committerGitHub <[email protected]>2020-07-27 09:06:18 +0100
commit91b2f0baafa5fe1827ed13c56721b5f505564e7c (patch)
treee47d887f72abf2e38df06956e0a7635c255acd5b /crates/ra_ssr/src/tests.rs
parent401a9c25151c1b659b8e80e2ffe70fa96a1f8ef1 (diff)
parentb3ca36b2d9fe5f2ef27cc19ced232e3168b77a38 (diff)
Merge #5539
5539: SSR: Fix path resolution of locals in current scope r=matklad a=davidlattimore Co-authored-by: David Lattimore <[email protected]>
Diffstat (limited to 'crates/ra_ssr/src/tests.rs')
-rw-r--r--crates/ra_ssr/src/tests.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs
index b38807c0f..18ef2506a 100644
--- a/crates/ra_ssr/src/tests.rs
+++ b/crates/ra_ssr/src/tests.rs
@@ -885,3 +885,40 @@ fn ufcs_matches_method_call() {
885 "#]], 885 "#]],
886 ); 886 );
887} 887}
888
889#[test]
890fn replace_local_variable_reference() {
891 // The pattern references a local variable `foo` in the block containing the cursor. We should
892 // only replace references to this variable `foo`, not other variables that just happen to have
893 // the same name.
894 mark::check!(cursor_after_semicolon);
895 assert_ssr_transform(
896 "foo + $a ==>> $a - foo",
897 r#"
898 fn bar1() -> i32 {
899 let mut res = 0;
900 let foo = 5;
901 res += foo + 1;
902 let foo = 10;
903 res += foo + 2;<|>
904 res += foo + 3;
905 let foo = 15;
906 res += foo + 4;
907 res
908 }
909 "#,
910 expect![[r#"
911 fn bar1() -> i32 {
912 let mut res = 0;
913 let foo = 5;
914 res += foo + 1;
915 let foo = 10;
916 res += 2 - foo;
917 res += 3 - foo;
918 let foo = 15;
919 res += foo + 4;
920 res
921 }
922 "#]],
923 )
924}