diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-13 13:34:12 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-13 13:34:12 +0100 |
commit | 10a243ea55565a0dd1de52f8f802c3e3a7bfef54 (patch) | |
tree | f7ef8597e4ba1bfbcd7f0e44e302b6452010a0e3 | |
parent | 9f18ba675fd1b60db6fb0f35264549969fddcee9 (diff) | |
parent | 43071e81a6e3a8270ffa5263d180226654768ede (diff) |
Merge #8507
8507: internal: follow test style guide in typing.rs r=jonas-schievink a=jonas-schievink
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r-- | crates/ide/src/typing.rs | 200 |
1 files changed, 104 insertions, 96 deletions
diff --git a/crates/ide/src/typing.rs b/crates/ide/src/typing.rs index 1378048e5..82c732390 100644 --- a/crates/ide/src/typing.rs +++ b/crates/ide/src/typing.rs | |||
@@ -222,8 +222,8 @@ mod tests { | |||
222 | assert_eq_text!(ra_fixture_after, &actual); | 222 | assert_eq_text!(ra_fixture_after, &actual); |
223 | } | 223 | } |
224 | 224 | ||
225 | fn type_char_noop(char_typed: char, before: &str) { | 225 | fn type_char_noop(char_typed: char, ra_fixture_before: &str) { |
226 | let file_change = do_type_char(char_typed, before); | 226 | let file_change = do_type_char(char_typed, ra_fixture_before); |
227 | assert!(file_change.is_none()) | 227 | assert!(file_change.is_none()) |
228 | } | 228 | } |
229 | 229 | ||
@@ -240,16 +240,16 @@ mod tests { | |||
240 | // "); | 240 | // "); |
241 | type_char( | 241 | type_char( |
242 | '=', | 242 | '=', |
243 | r" | 243 | r#" |
244 | fn foo() { | 244 | fn foo() { |
245 | let foo $0 1 + 1 | 245 | let foo $0 1 + 1 |
246 | } | 246 | } |
247 | ", | 247 | "#, |
248 | r" | 248 | r#" |
249 | fn foo() { | 249 | fn foo() { |
250 | let foo = 1 + 1; | 250 | let foo = 1 + 1; |
251 | } | 251 | } |
252 | ", | 252 | "#, |
253 | ); | 253 | ); |
254 | // do_check(r" | 254 | // do_check(r" |
255 | // fn foo() { | 255 | // fn foo() { |
@@ -268,27 +268,27 @@ fn foo() { | |||
268 | fn indents_new_chain_call() { | 268 | fn indents_new_chain_call() { |
269 | type_char( | 269 | type_char( |
270 | '.', | 270 | '.', |
271 | r" | 271 | r#" |
272 | fn main() { | 272 | fn main() { |
273 | xs.foo() | 273 | xs.foo() |
274 | $0 | 274 | $0 |
275 | } | 275 | } |
276 | ", | 276 | "#, |
277 | r" | 277 | r#" |
278 | fn main() { | 278 | fn main() { |
279 | xs.foo() | 279 | xs.foo() |
280 | . | 280 | . |
281 | } | 281 | } |
282 | ", | 282 | "#, |
283 | ); | 283 | ); |
284 | type_char_noop( | 284 | type_char_noop( |
285 | '.', | 285 | '.', |
286 | r" | 286 | r#" |
287 | fn main() { | 287 | fn main() { |
288 | xs.foo() | 288 | xs.foo() |
289 | $0 | 289 | $0 |
290 | } | 290 | } |
291 | ", | 291 | "#, |
292 | ) | 292 | ) |
293 | } | 293 | } |
294 | 294 | ||
@@ -297,26 +297,26 @@ fn foo() { | |||
297 | type_char( | 297 | type_char( |
298 | '.', | 298 | '.', |
299 | r" | 299 | r" |
300 | fn main() { | 300 | fn main() { |
301 | xs.foo() | 301 | xs.foo() |
302 | $0; | 302 | $0; |
303 | } | 303 | } |
304 | ", | ||
305 | r" | ||
306 | fn main() { | ||
307 | xs.foo() | ||
308 | .; | ||
309 | } | ||
310 | ", | 304 | ", |
305 | r#" | ||
306 | fn main() { | ||
307 | xs.foo() | ||
308 | .; | ||
309 | } | ||
310 | "#, | ||
311 | ); | 311 | ); |
312 | type_char_noop( | 312 | type_char_noop( |
313 | '.', | 313 | '.', |
314 | r" | 314 | r#" |
315 | fn main() { | 315 | fn main() { |
316 | xs.foo() | 316 | xs.foo() |
317 | $0; | 317 | $0; |
318 | } | 318 | } |
319 | ", | 319 | "#, |
320 | ) | 320 | ) |
321 | } | 321 | } |
322 | 322 | ||
@@ -345,30 +345,30 @@ fn main() { | |||
345 | fn indents_continued_chain_call() { | 345 | fn indents_continued_chain_call() { |
346 | type_char( | 346 | type_char( |
347 | '.', | 347 | '.', |
348 | r" | 348 | r#" |
349 | fn main() { | 349 | fn main() { |
350 | xs.foo() | 350 | xs.foo() |
351 | .first() | 351 | .first() |
352 | $0 | 352 | $0 |
353 | } | 353 | } |
354 | ", | 354 | "#, |
355 | r" | 355 | r#" |
356 | fn main() { | 356 | fn main() { |
357 | xs.foo() | 357 | xs.foo() |
358 | .first() | 358 | .first() |
359 | . | 359 | . |
360 | } | 360 | } |
361 | ", | 361 | "#, |
362 | ); | 362 | ); |
363 | type_char_noop( | 363 | type_char_noop( |
364 | '.', | 364 | '.', |
365 | r" | 365 | r#" |
366 | fn main() { | 366 | fn main() { |
367 | xs.foo() | 367 | xs.foo() |
368 | .first() | 368 | .first() |
369 | $0 | 369 | $0 |
370 | } | 370 | } |
371 | ", | 371 | "#, |
372 | ); | 372 | ); |
373 | } | 373 | } |
374 | 374 | ||
@@ -376,33 +376,33 @@ fn main() { | |||
376 | fn indents_middle_of_chain_call() { | 376 | fn indents_middle_of_chain_call() { |
377 | type_char( | 377 | type_char( |
378 | '.', | 378 | '.', |
379 | r" | 379 | r#" |
380 | fn source_impl() { | 380 | fn source_impl() { |
381 | let var = enum_defvariant_list().unwrap() | 381 | let var = enum_defvariant_list().unwrap() |
382 | $0 | 382 | $0 |
383 | .nth(92) | 383 | .nth(92) |
384 | .unwrap(); | 384 | .unwrap(); |
385 | } | 385 | } |
386 | ", | 386 | "#, |
387 | r" | 387 | r#" |
388 | fn source_impl() { | 388 | fn source_impl() { |
389 | let var = enum_defvariant_list().unwrap() | 389 | let var = enum_defvariant_list().unwrap() |
390 | . | 390 | . |
391 | .nth(92) | 391 | .nth(92) |
392 | .unwrap(); | 392 | .unwrap(); |
393 | } | 393 | } |
394 | ", | 394 | "#, |
395 | ); | 395 | ); |
396 | type_char_noop( | 396 | type_char_noop( |
397 | '.', | 397 | '.', |
398 | r" | 398 | r#" |
399 | fn source_impl() { | 399 | fn source_impl() { |
400 | let var = enum_defvariant_list().unwrap() | 400 | let var = enum_defvariant_list().unwrap() |
401 | $0 | 401 | $0 |
402 | .nth(92) | 402 | .nth(92) |
403 | .unwrap(); | 403 | .unwrap(); |
404 | } | 404 | } |
405 | ", | 405 | "#, |
406 | ); | 406 | ); |
407 | } | 407 | } |
408 | 408 | ||
@@ -410,25 +410,33 @@ fn main() { | |||
410 | fn dont_indent_freestanding_dot() { | 410 | fn dont_indent_freestanding_dot() { |
411 | type_char_noop( | 411 | type_char_noop( |
412 | '.', | 412 | '.', |
413 | r" | 413 | r#" |
414 | fn main() { | 414 | fn main() { |
415 | $0 | 415 | $0 |
416 | } | 416 | } |
417 | ", | 417 | "#, |
418 | ); | 418 | ); |
419 | type_char_noop( | 419 | type_char_noop( |
420 | '.', | 420 | '.', |
421 | r" | 421 | r#" |
422 | fn main() { | 422 | fn main() { |
423 | $0 | 423 | $0 |
424 | } | 424 | } |
425 | ", | 425 | "#, |
426 | ); | 426 | ); |
427 | } | 427 | } |
428 | 428 | ||
429 | #[test] | 429 | #[test] |
430 | fn adds_space_after_return_type() { | 430 | fn adds_space_after_return_type() { |
431 | type_char('>', "fn foo() -$0{ 92 }", "fn foo() -> { 92 }") | 431 | type_char( |
432 | '>', | ||
433 | r#" | ||
434 | fn foo() -$0{ 92 } | ||
435 | "#, | ||
436 | r#" | ||
437 | fn foo() -> { 92 } | ||
438 | "#, | ||
439 | ); | ||
432 | } | 440 | } |
433 | 441 | ||
434 | #[test] | 442 | #[test] |