aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-05-23 21:19:00 +0100
committerAleksey Kladov <[email protected]>2021-05-23 21:19:00 +0100
commitaf54b1e248f377853957ada0270e269bedb577b4 (patch)
treecb637a226f131f693a59ba94be8f0ad9974855d3 /crates/ide_assists
parentc06599504bc4fcbb3d5024d9a8bdb14f263bad36 (diff)
minimize tests
Diffstat (limited to 'crates/ide_assists')
-rw-r--r--crates/ide_assists/src/handlers/generate_getter.rs98
1 files changed, 54 insertions, 44 deletions
diff --git a/crates/ide_assists/src/handlers/generate_getter.rs b/crates/ide_assists/src/handlers/generate_getter.rs
index fbd47d761..c77395824 100644
--- a/crates/ide_assists/src/handlers/generate_getter.rs
+++ b/crates/ide_assists/src/handlers/generate_getter.rs
@@ -135,39 +135,43 @@ mod tests {
135 check_assist( 135 check_assist(
136 generate_getter, 136 generate_getter,
137 r#" 137 r#"
138struct Context<T: Clone> { 138struct Context {
139 dat$0a: T, 139 dat$0a: Data,
140}"#, 140}
141"#,
141 r#" 142 r#"
142struct Context<T: Clone> { 143struct Context {
143 data: T, 144 data: Data,
144} 145}
145 146
146impl<T: Clone> Context<T> { 147impl Context {
147 /// Get a reference to the context's data. 148 /// Get a reference to the context's data.
148 fn data(&self) -> &T { 149 fn data(&self) -> &Data {
149 &self.data 150 &self.data
150 } 151 }
151}"#, 152}
153"#,
152 ); 154 );
153 155
154 check_assist( 156 check_assist(
155 generate_getter_mut, 157 generate_getter_mut,
156 r#" 158 r#"
157struct Context<T: Clone> { 159struct Context {
158 dat$0a: T, 160 dat$0a: Data,
159}"#, 161}
162"#,
160 r#" 163 r#"
161struct Context<T: Clone> { 164struct Context {
162 data: T, 165 data: Data,
163} 166}
164 167
165impl<T: Clone> Context<T> { 168impl Context {
166 /// Get a mutable reference to the context's data. 169 /// Get a mutable reference to the context's data.
167 fn data_mut(&mut self) -> &mut T { 170 fn data_mut(&mut self) -> &mut Data {
168 &mut self.data 171 &mut self.data
169 } 172 }
170}"#, 173}
174"#,
171 ); 175 );
172 } 176 }
173 177
@@ -176,29 +180,31 @@ impl<T: Clone> Context<T> {
176 check_assist_not_applicable( 180 check_assist_not_applicable(
177 generate_getter, 181 generate_getter,
178 r#" 182 r#"
179struct Context<T: Clone> { 183struct Context {
180 dat$0a: T, 184 dat$0a: Data,
181} 185}
182 186
183impl<T: Clone> Context<T> { 187impl Context {
184 fn data(&self) -> &T { 188 fn data(&self) -> &Data {
185 &self.data 189 &self.data
186 } 190 }
187}"#, 191}
192"#,
188 ); 193 );
189 194
190 check_assist_not_applicable( 195 check_assist_not_applicable(
191 generate_getter_mut, 196 generate_getter_mut,
192 r#" 197 r#"
193struct Context<T: Clone> { 198struct Context {
194 dat$0a: T, 199 dat$0a: Data,
195} 200}
196 201
197impl<T: Clone> Context<T> { 202impl Context {
198 fn data_mut(&mut self) -> &mut T { 203 fn data_mut(&mut self) -> &mut Data {
199 &mut self.data 204 &mut self.data
200 } 205 }
201}"#, 206}
207"#,
202 ); 208 );
203 } 209 }
204 210
@@ -207,20 +213,22 @@ impl<T: Clone> Context<T> {
207 check_assist( 213 check_assist(
208 generate_getter, 214 generate_getter,
209 r#" 215 r#"
210pub(crate) struct Context<T: Clone> { 216pub(crate) struct Context {
211 dat$0a: T, 217 dat$0a: Data,
212}"#, 218}
219"#,
213 r#" 220 r#"
214pub(crate) struct Context<T: Clone> { 221pub(crate) struct Context {
215 data: T, 222 data: Data,
216} 223}
217 224
218impl<T: Clone> Context<T> { 225impl Context {
219 /// Get a reference to the context's data. 226 /// Get a reference to the context's data.
220 pub(crate) fn data(&self) -> &T { 227 pub(crate) fn data(&self) -> &Data {
221 &self.data 228 &self.data
222 } 229 }
223}"#, 230}
231"#,
224 ); 232 );
225 } 233 }
226 234
@@ -229,26 +237,27 @@ impl<T: Clone> Context<T> {
229 check_assist( 237 check_assist(
230 generate_getter, 238 generate_getter,
231 r#" 239 r#"
232struct Context<T: Clone> { 240struct Context {
233 data: T, 241 data: Data,
234 cou$0nt: usize, 242 cou$0nt: usize,
235} 243}
236 244
237impl<T: Clone> Context<T> { 245impl Context {
238 /// Get a reference to the context's data. 246 /// Get a reference to the context's data.
239 fn data(&self) -> &T { 247 fn data(&self) -> &Data {
240 &self.data 248 &self.data
241 } 249 }
242}"#, 250}
251"#,
243 r#" 252 r#"
244struct Context<T: Clone> { 253struct Context {
245 data: T, 254 data: Data,
246 count: usize, 255 count: usize,
247} 256}
248 257
249impl<T: Clone> Context<T> { 258impl Context {
250 /// Get a reference to the context's data. 259 /// Get a reference to the context's data.
251 fn data(&self) -> &T { 260 fn data(&self) -> &Data {
252 &self.data 261 &self.data
253 } 262 }
254 263
@@ -256,7 +265,8 @@ impl<T: Clone> Context<T> {
256 fn count(&self) -> &usize { 265 fn count(&self) -> &usize {
257 &self.count 266 &self.count
258 } 267 }
259}"#, 268}
269"#,
260 ); 270 );
261 } 271 }
262} 272}