diff options
Diffstat (limited to 'crates/ra_ssr/src/tests.rs')
-rw-r--r-- | crates/ra_ssr/src/tests.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index 0a49a46e3..7d4d470c0 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs | |||
@@ -1108,3 +1108,38 @@ fn replace_nonpath_within_selection() { | |||
1108 | }"#]], | 1108 | }"#]], |
1109 | ); | 1109 | ); |
1110 | } | 1110 | } |
1111 | |||
1112 | #[test] | ||
1113 | fn replace_self() { | ||
1114 | // `foo(self)` occurs twice in the code, however only the first occurrence is the `self` that's | ||
1115 | // in scope where the rule is invoked. | ||
1116 | assert_ssr_transform( | ||
1117 | "foo(self) ==>> bar(self)", | ||
1118 | r#" | ||
1119 | struct S1 {} | ||
1120 | fn foo(_: &S1) {} | ||
1121 | fn bar(_: &S1) {} | ||
1122 | impl S1 { | ||
1123 | fn f1(&self) { | ||
1124 | foo(self)<|> | ||
1125 | } | ||
1126 | fn f2(&self) { | ||
1127 | foo(self) | ||
1128 | } | ||
1129 | } | ||
1130 | "#, | ||
1131 | expect![[r#" | ||
1132 | struct S1 {} | ||
1133 | fn foo(_: &S1) {} | ||
1134 | fn bar(_: &S1) {} | ||
1135 | impl S1 { | ||
1136 | fn f1(&self) { | ||
1137 | bar(self) | ||
1138 | } | ||
1139 | fn f2(&self) { | ||
1140 | foo(self) | ||
1141 | } | ||
1142 | } | ||
1143 | "#]], | ||
1144 | ); | ||
1145 | } | ||