aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-05-16 13:14:57 +0100
committerAleksey Kladov <[email protected]>2021-05-16 13:14:57 +0100
commit9df0a2336829c54fbbc57ee8c8585aff345d9e47 (patch)
treec3d84a9e3535cb65026a9c6230a27d12c05afebf /crates
parente4a7b44e554e183fc66474bcbd8f7ace541c5536 (diff)
internal: use standard test style
Diffstat (limited to 'crates')
-rw-r--r--crates/ide_assists/src/handlers/fill_match_arms.rs609
1 files changed, 305 insertions, 304 deletions
diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs
index f66a9b54b..58b001050 100644
--- a/crates/ide_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ide_assists/src/handlers/fill_match_arms.rs
@@ -275,18 +275,18 @@ mod tests {
275 check_assist_not_applicable( 275 check_assist_not_applicable(
276 fill_match_arms, 276 fill_match_arms,
277 r#" 277 r#"
278 enum A { 278enum A {
279 As, 279 As,
280 Bs{x:i32, y:Option<i32>}, 280 Bs{x:i32, y:Option<i32>},
281 Cs(i32, Option<i32>), 281 Cs(i32, Option<i32>),
282 } 282}
283 fn main() { 283fn main() {
284 match A::As$0 { 284 match A::As$0 {
285 A::As, 285 A::As,
286 A::Bs{x,y:Some(_)} => {} 286 A::Bs{x,y:Some(_)} => {}
287 A::Cs(_, Some(_)) => {} 287 A::Cs(_, Some(_)) => {}
288 } 288 }
289 } 289}
290 "#, 290 "#,
291 ); 291 );
292 } 292 }
@@ -296,13 +296,13 @@ mod tests {
296 check_assist_not_applicable( 296 check_assist_not_applicable(
297 fill_match_arms, 297 fill_match_arms,
298 r#" 298 r#"
299 fn foo(a: bool) { 299fn foo(a: bool) {
300 match a$0 { 300 match a$0 {
301 true => {} 301 true => {}
302 false => {} 302 false => {}
303 } 303 }
304 } 304}
305 "#, 305"#,
306 ) 306 )
307 } 307 }
308 308
@@ -313,11 +313,11 @@ mod tests {
313 check_assist_not_applicable( 313 check_assist_not_applicable(
314 fill_match_arms, 314 fill_match_arms,
315 r#" 315 r#"
316 fn main() { 316fn main() {
317 match (0, false)$0 { 317 match (0, false)$0 {
318 } 318 }
319 } 319}
320 "#, 320"#,
321 ); 321 );
322 } 322 }
323 323
@@ -326,19 +326,19 @@ mod tests {
326 check_assist( 326 check_assist(
327 fill_match_arms, 327 fill_match_arms,
328 r#" 328 r#"
329 fn foo(a: bool) { 329fn foo(a: bool) {
330 match a$0 { 330 match a$0 {
331 } 331 }
332 } 332}
333 "#, 333"#,
334 r#" 334 r#"
335 fn foo(a: bool) { 335fn foo(a: bool) {
336 match a { 336 match a {
337 $0true => {} 337 $0true => {}
338 false => {} 338 false => {}
339 } 339 }
340 } 340}
341 "#, 341"#,
342 ) 342 )
343 } 343 }
344 344
@@ -347,20 +347,20 @@ mod tests {
347 check_assist( 347 check_assist(
348 fill_match_arms, 348 fill_match_arms,
349 r#" 349 r#"
350 fn foo(a: bool) { 350fn foo(a: bool) {
351 match a$0 { 351 match a$0 {
352 true => {} 352 true => {}
353 } 353 }
354 } 354}
355 "#, 355"#,
356 r#" 356 r#"
357 fn foo(a: bool) { 357fn foo(a: bool) {
358 match a { 358 match a {
359 true => {} 359 true => {}
360 $0false => {} 360 $0false => {}
361 } 361 }
362 } 362}
363 "#, 363"#,
364 ) 364 )
365 } 365 }
366 366
@@ -369,15 +369,15 @@ mod tests {
369 check_assist_not_applicable( 369 check_assist_not_applicable(
370 fill_match_arms, 370 fill_match_arms,
371 r#" 371 r#"
372 fn foo(a: bool) { 372fn foo(a: bool) {
373 match (a, a)$0 { 373 match (a, a)$0 {
374 (true, true) => {} 374 (true, true) => {}
375 (true, false) => {} 375 (true, false) => {}
376 (false, true) => {} 376 (false, true) => {}
377 (false, false) => {} 377 (false, false) => {}
378 } 378 }
379 } 379}
380 "#, 380"#,
381 ) 381 )
382 } 382 }
383 383
@@ -386,21 +386,21 @@ mod tests {
386 check_assist( 386 check_assist(
387 fill_match_arms, 387 fill_match_arms,
388 r#" 388 r#"
389 fn foo(a: bool) { 389fn foo(a: bool) {
390 match (a, a)$0 { 390 match (a, a)$0 {
391 } 391 }
392 } 392}
393 "#, 393"#,
394 r#" 394 r#"
395 fn foo(a: bool) { 395fn foo(a: bool) {
396 match (a, a) { 396 match (a, a) {
397 $0(true, true) => {} 397 $0(true, true) => {}
398 (true, false) => {} 398 (true, false) => {}
399 (false, true) => {} 399 (false, true) => {}
400 (false, false) => {} 400 (false, false) => {}
401 } 401 }
402 } 402}
403 "#, 403"#,
404 ) 404 )
405 } 405 }
406 406
@@ -409,22 +409,22 @@ mod tests {
409 check_assist( 409 check_assist(
410 fill_match_arms, 410 fill_match_arms,
411 r#" 411 r#"
412 fn foo(a: bool) { 412fn foo(a: bool) {
413 match (a, a)$0 { 413 match (a, a)$0 {
414 (false, true) => {} 414 (false, true) => {}
415 } 415 }
416 } 416}
417 "#, 417"#,
418 r#" 418 r#"
419 fn foo(a: bool) { 419fn foo(a: bool) {
420 match (a, a) { 420 match (a, a) {
421 (false, true) => {} 421 (false, true) => {}
422 $0(true, true) => {} 422 $0(true, true) => {}
423 (true, false) => {} 423 (true, false) => {}
424 (false, false) => {} 424 (false, false) => {}
425 } 425 }
426 } 426}
427 "#, 427"#,
428 ) 428 )
429 } 429 }
430 430
@@ -433,32 +433,32 @@ mod tests {
433 check_assist( 433 check_assist(
434 fill_match_arms, 434 fill_match_arms,
435 r#" 435 r#"
436 enum A { 436enum A {
437 As, 437 As,
438 Bs { x: i32, y: Option<i32> }, 438 Bs { x: i32, y: Option<i32> },
439 Cs(i32, Option<i32>), 439 Cs(i32, Option<i32>),
440 } 440}
441 fn main() { 441fn main() {
442 match A::As$0 { 442 match A::As$0 {
443 A::Bs { x, y: Some(_) } => {} 443 A::Bs { x, y: Some(_) } => {}
444 A::Cs(_, Some(_)) => {} 444 A::Cs(_, Some(_)) => {}
445 } 445 }
446 } 446}
447 "#, 447"#,
448 r#" 448 r#"
449 enum A { 449enum A {
450 As, 450 As,
451 Bs { x: i32, y: Option<i32> }, 451 Bs { x: i32, y: Option<i32> },
452 Cs(i32, Option<i32>), 452 Cs(i32, Option<i32>),
453 } 453}
454 fn main() { 454fn main() {
455 match A::As { 455 match A::As {
456 A::Bs { x, y: Some(_) } => {} 456 A::Bs { x, y: Some(_) } => {}
457 A::Cs(_, Some(_)) => {} 457 A::Cs(_, Some(_)) => {}
458 $0A::As => {} 458 $0A::As => {}
459 } 459 }
460 } 460}
461 "#, 461"#,
462 ); 462 );
463 } 463 }
464 464
@@ -605,30 +605,30 @@ fn main() {
605 check_assist( 605 check_assist(
606 fill_match_arms, 606 fill_match_arms,
607 r#" 607 r#"
608 enum A { One, Two } 608enum A { One, Two }
609 enum B { One, Two } 609enum B { One, Two }
610 610
611 fn main() { 611fn main() {
612 let a = A::One; 612 let a = A::One;
613 let b = B::One; 613 let b = B::One;
614 match (a$0, b) {} 614 match (a$0, b) {}
615 } 615}
616 "#, 616"#,
617 r#" 617 r#"
618 enum A { One, Two } 618enum A { One, Two }
619 enum B { One, Two } 619enum B { One, Two }
620 620
621 fn main() { 621fn main() {
622 let a = A::One; 622 let a = A::One;
623 let b = B::One; 623 let b = B::One;
624 match (a, b) { 624 match (a, b) {
625 $0(A::One, B::One) => {} 625 $0(A::One, B::One) => {}
626 (A::One, B::Two) => {} 626 (A::One, B::Two) => {}
627 (A::Two, B::One) => {} 627 (A::Two, B::One) => {}
628 (A::Two, B::Two) => {} 628 (A::Two, B::Two) => {}
629 } 629 }
630 } 630}
631 "#, 631"#,
632 ); 632 );
633 } 633 }
634 634
@@ -637,30 +637,30 @@ fn main() {
637 check_assist( 637 check_assist(
638 fill_match_arms, 638 fill_match_arms,
639 r#" 639 r#"
640 enum A { One, Two } 640enum A { One, Two }
641 enum B { One, Two } 641enum B { One, Two }
642 642
643 fn main() { 643fn main() {
644 let a = A::One; 644 let a = A::One;
645 let b = B::One; 645 let b = B::One;
646 match (&a$0, &b) {} 646 match (&a$0, &b) {}
647 } 647}
648 "#, 648"#,
649 r#" 649 r#"
650 enum A { One, Two } 650enum A { One, Two }
651 enum B { One, Two } 651enum B { One, Two }
652 652
653 fn main() { 653fn main() {
654 let a = A::One; 654 let a = A::One;
655 let b = B::One; 655 let b = B::One;
656 match (&a, &b) { 656 match (&a, &b) {
657 $0(A::One, B::One) => {} 657 $0(A::One, B::One) => {}
658 (A::One, B::Two) => {} 658 (A::One, B::Two) => {}
659 (A::Two, B::One) => {} 659 (A::Two, B::One) => {}
660 (A::Two, B::Two) => {} 660 (A::Two, B::Two) => {}
661 } 661 }
662 } 662}
663 "#, 663"#,
664 ); 664 );
665 } 665 }
666 666
@@ -749,20 +749,20 @@ fn main() {
749 check_assist_not_applicable( 749 check_assist_not_applicable(
750 fill_match_arms, 750 fill_match_arms,
751 r#" 751 r#"
752 enum A { One, Two } 752enum A { One, Two }
753 enum B { One, Two } 753enum B { One, Two }
754 754
755 fn main() { 755fn main() {
756 let a = A::One; 756 let a = A::One;
757 let b = B::One; 757 let b = B::One;
758 match (a$0, b) { 758 match (a$0, b) {
759 (A::Two, B::One) => {} 759 (A::Two, B::One) => {}
760 (A::One, B::One) => {} 760 (A::One, B::One) => {}
761 (A::One, B::Two) => {} 761 (A::One, B::Two) => {}
762 (A::Two, B::Two) => {} 762 (A::Two, B::Two) => {}
763 } 763 }
764 } 764}
765 "#, 765"#,
766 ); 766 );
767 } 767 }
768 768
@@ -771,25 +771,25 @@ fn main() {
771 check_assist( 771 check_assist(
772 fill_match_arms, 772 fill_match_arms,
773 r#" 773 r#"
774 enum A { One, Two } 774enum A { One, Two }
775 775
776 fn main() { 776fn main() {
777 let a = A::One; 777 let a = A::One;
778 match (a$0, ) { 778 match (a$0, ) {
779 } 779 }
780 } 780}
781 "#, 781"#,
782 r#" 782 r#"
783 enum A { One, Two } 783enum A { One, Two }
784 784
785 fn main() { 785fn main() {
786 let a = A::One; 786 let a = A::One;
787 match (a, ) { 787 match (a, ) {
788 $0(A::One,) => {} 788 $0(A::One,) => {}
789 (A::Two,) => {} 789 (A::Two,) => {}
790 } 790 }
791 } 791}
792 "#, 792"#,
793 ); 793 );
794 } 794 }
795 795
@@ -798,47 +798,47 @@ fn main() {
798 check_assist( 798 check_assist(
799 fill_match_arms, 799 fill_match_arms,
800 r#" 800 r#"
801 enum A { As } 801enum A { As }
802 802
803 fn foo(a: &A) { 803fn foo(a: &A) {
804 match a$0 { 804 match a$0 {
805 } 805 }
806 } 806}
807 "#, 807"#,
808 r#" 808 r#"
809 enum A { As } 809enum A { As }
810 810
811 fn foo(a: &A) { 811fn foo(a: &A) {
812 match a { 812 match a {
813 $0A::As => {} 813 $0A::As => {}
814 } 814 }
815 } 815}
816 "#, 816"#,
817 ); 817 );
818 818
819 check_assist( 819 check_assist(
820 fill_match_arms, 820 fill_match_arms,
821 r#" 821 r#"
822 enum A { 822enum A {
823 Es { x: usize, y: usize } 823 Es { x: usize, y: usize }
824 } 824}
825 825
826 fn foo(a: &mut A) { 826fn foo(a: &mut A) {
827 match a$0 { 827 match a$0 {
828 } 828 }
829 } 829}
830 "#, 830"#,
831 r#" 831 r#"
832 enum A { 832enum A {
833 Es { x: usize, y: usize } 833 Es { x: usize, y: usize }
834 } 834}
835 835
836 fn foo(a: &mut A) { 836fn foo(a: &mut A) {
837 match a { 837 match a {
838 $0A::Es { x, y } => {} 838 $0A::Es { x, y } => {}
839 } 839 }
840 } 840}
841 "#, 841"#,
842 ); 842 );
843 } 843 }
844 844
@@ -847,12 +847,12 @@ fn main() {
847 check_assist_target( 847 check_assist_target(
848 fill_match_arms, 848 fill_match_arms,
849 r#" 849 r#"
850 enum E { X, Y } 850enum E { X, Y }
851 851
852 fn main() { 852fn main() {
853 match E::X$0 {} 853 match E::X$0 {}
854 } 854}
855 "#, 855"#,
856 "match E::X {}", 856 "match E::X {}",
857 ); 857 );
858 } 858 }
@@ -862,24 +862,24 @@ fn main() {
862 check_assist( 862 check_assist(
863 fill_match_arms, 863 fill_match_arms,
864 r#" 864 r#"
865 enum E { X, Y } 865enum E { X, Y }
866 866
867 fn main() { 867fn main() {
868 match E::X { 868 match E::X {
869 $0_ => {} 869 $0_ => {}
870 } 870 }
871 } 871}
872 "#, 872"#,
873 r#" 873 r#"
874 enum E { X, Y } 874enum E { X, Y }
875 875
876 fn main() { 876fn main() {
877 match E::X { 877 match E::X {
878 $0E::X => {} 878 $0E::X => {}
879 E::Y => {} 879 E::Y => {}
880 } 880 }
881 } 881}
882 "#, 882"#,
883 ); 883 );
884 } 884 }
885 885
@@ -888,26 +888,26 @@ fn main() {
888 check_assist( 888 check_assist(
889 fill_match_arms, 889 fill_match_arms,
890 r#" 890 r#"
891 mod foo { pub enum E { X, Y } } 891mod foo { pub enum E { X, Y } }
892 use foo::E::X; 892use foo::E::X;
893 893
894 fn main() { 894fn main() {
895 match X { 895 match X {
896 $0 896 $0
897 } 897 }
898 } 898}
899 "#, 899"#,
900 r#" 900 r#"
901 mod foo { pub enum E { X, Y } } 901mod foo { pub enum E { X, Y } }
902 use foo::E::X; 902use foo::E::X;
903 903
904 fn main() { 904fn main() {
905 match X { 905 match X {
906 $0X => {} 906 $0X => {}
907 foo::E::Y => {} 907 foo::E::Y => {}
908 } 908 }
909 } 909}
910 "#, 910"#,
911 ); 911 );
912 } 912 }
913 913
@@ -916,26 +916,26 @@ fn main() {
916 check_assist( 916 check_assist(
917 fill_match_arms, 917 fill_match_arms,
918 r#" 918 r#"
919 enum A { One, Two } 919enum A { One, Two }
920 fn foo(a: A) { 920fn foo(a: A) {
921 match a { 921 match a {
922 // foo bar baz$0 922 // foo bar baz$0
923 A::One => {} 923 A::One => {}
924 // This is where the rest should be 924 // This is where the rest should be
925 } 925 }
926 } 926}
927 "#, 927"#,
928 r#" 928 r#"
929 enum A { One, Two } 929enum A { One, Two }
930 fn foo(a: A) { 930fn foo(a: A) {
931 match a { 931 match a {
932 // foo bar baz 932 // foo bar baz
933 A::One => {} 933 A::One => {}
934 $0A::Two => {} 934 $0A::Two => {}
935 // This is where the rest should be 935 // This is where the rest should be
936 } 936 }
937 } 937}
938 "#, 938"#,
939 ); 939 );
940 } 940 }
941 941
@@ -944,23 +944,23 @@ fn main() {
944 check_assist( 944 check_assist(
945 fill_match_arms, 945 fill_match_arms,
946 r#" 946 r#"
947 enum A { One, Two } 947enum A { One, Two }
948 fn foo(a: A) { 948fn foo(a: A) {
949 match a { 949 match a {
950 // foo bar baz$0 950 // foo bar baz$0
951 } 951 }
952 } 952}
953 "#, 953"#,
954 r#" 954 r#"
955 enum A { One, Two } 955enum A { One, Two }
956 fn foo(a: A) { 956fn foo(a: A) {
957 match a { 957 match a {
958 $0A::One => {} 958 $0A::One => {}
959 A::Two => {} 959 A::Two => {}
960 // foo bar baz 960 // foo bar baz
961 } 961 }
962 } 962}
963 "#, 963"#,
964 ); 964 );
965 } 965 }
966 966
@@ -969,22 +969,22 @@ fn main() {
969 check_assist( 969 check_assist(
970 fill_match_arms, 970 fill_match_arms,
971 r#" 971 r#"
972 enum A { One, Two, } 972enum A { One, Two, }
973 fn foo(a: A) { 973fn foo(a: A) {
974 match a$0 { 974 match a$0 {
975 _ => (), 975 _ => (),
976 } 976 }
977 } 977}
978 "#, 978"#,
979 r#" 979 r#"
980 enum A { One, Two, } 980enum A { One, Two, }
981 fn foo(a: A) { 981fn foo(a: A) {
982 match a { 982 match a {
983 $0A::One => {} 983 $0A::One => {}
984 A::Two => {} 984 A::Two => {}
985 } 985 }
986 } 986}
987 "#, 987"#,
988 ); 988 );
989 } 989 }
990 990
@@ -1028,7 +1028,8 @@ enum Test {
1028fn foo(t: Test) { 1028fn foo(t: Test) {
1029 m!(match t$0 {}); 1029 m!(match t$0 {});
1030}"#, 1030}"#,
1031 r#"macro_rules! m { ($expr:expr) => {$expr}} 1031 r#"
1032macro_rules! m { ($expr:expr) => {$expr}}
1032enum Test { 1033enum Test {
1033 A, 1034 A,
1034 B, 1035 B,