diff options
author | Aleksey Kladov <[email protected]> | 2020-07-04 08:07:18 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-04 08:07:18 +0100 |
commit | 6518f18f80d5bf0b5dc66320af8b0924918c97d3 (patch) | |
tree | 6a0f89f54975d5911c8827477a903aa1fab83872 /crates/ra_ide/src | |
parent | 212fa29a69af5f0f0de30a1d450bb4cd978a0c3e (diff) |
Cleanup tests
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 234 |
1 files changed, 62 insertions, 172 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index fd12673b2..8026170da 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -844,189 +844,79 @@ fn f(foo: &Foo) { foo.foo(); } | |||
844 | #[test] | 844 | #[test] |
845 | fn inserts_angle_brackets_for_generics() { | 845 | fn inserts_angle_brackets_for_generics() { |
846 | mark::check!(inserts_angle_brackets_for_generics); | 846 | mark::check!(inserts_angle_brackets_for_generics); |
847 | assert_debug_snapshot!( | 847 | check_edit( |
848 | do_reference_completion( | 848 | "Vec", |
849 | r" | 849 | r#" |
850 | struct Vec<T> {} | 850 | struct Vec<T> {} |
851 | fn foo(xs: Ve<|>) | 851 | fn foo(xs: Ve<|>) |
852 | " | 852 | "#, |
853 | ), | 853 | r#" |
854 | @r###" | 854 | struct Vec<T> {} |
855 | [ | 855 | fn foo(xs: Vec<$0>) |
856 | CompletionItem { | 856 | "#, |
857 | label: "Vec<…>", | ||
858 | source_range: 28..30, | ||
859 | delete: 28..30, | ||
860 | insert: "Vec<$0>", | ||
861 | kind: Struct, | ||
862 | lookup: "Vec", | ||
863 | }, | ||
864 | CompletionItem { | ||
865 | label: "foo(…)", | ||
866 | source_range: 28..30, | ||
867 | delete: 28..30, | ||
868 | insert: "foo(${1:xs})$0", | ||
869 | kind: Function, | ||
870 | lookup: "foo", | ||
871 | detail: "fn foo(xs: Ve)", | ||
872 | trigger_call_info: true, | ||
873 | }, | ||
874 | ] | ||
875 | "### | ||
876 | ); | 857 | ); |
877 | assert_debug_snapshot!( | 858 | check_edit( |
878 | do_reference_completion( | 859 | "Vec", |
879 | r" | 860 | r#" |
880 | type Vec<T> = (T,); | 861 | type Vec<T> = (T,); |
881 | fn foo(xs: Ve<|>) | 862 | fn foo(xs: Ve<|>) |
882 | " | 863 | "#, |
883 | ), | 864 | r#" |
884 | @r###" | 865 | type Vec<T> = (T,); |
885 | [ | 866 | fn foo(xs: Vec<$0>) |
886 | CompletionItem { | 867 | "#, |
887 | label: "Vec<…>", | ||
888 | source_range: 31..33, | ||
889 | delete: 31..33, | ||
890 | insert: "Vec<$0>", | ||
891 | kind: TypeAlias, | ||
892 | lookup: "Vec", | ||
893 | }, | ||
894 | CompletionItem { | ||
895 | label: "foo(…)", | ||
896 | source_range: 31..33, | ||
897 | delete: 31..33, | ||
898 | insert: "foo(${1:xs})$0", | ||
899 | kind: Function, | ||
900 | lookup: "foo", | ||
901 | detail: "fn foo(xs: Ve)", | ||
902 | trigger_call_info: true, | ||
903 | }, | ||
904 | ] | ||
905 | "### | ||
906 | ); | 868 | ); |
907 | assert_debug_snapshot!( | 869 | check_edit( |
908 | do_reference_completion( | 870 | "Vec", |
909 | r" | 871 | r#" |
910 | struct Vec<T = i128> {} | 872 | struct Vec<T = i128> {} |
911 | fn foo(xs: Ve<|>) | 873 | fn foo(xs: Ve<|>) |
912 | " | 874 | "#, |
913 | ), | 875 | r#" |
914 | @r###" | 876 | struct Vec<T = i128> {} |
915 | [ | 877 | fn foo(xs: Vec) |
916 | CompletionItem { | 878 | "#, |
917 | label: "Vec", | ||
918 | source_range: 35..37, | ||
919 | delete: 35..37, | ||
920 | insert: "Vec", | ||
921 | kind: Struct, | ||
922 | }, | ||
923 | CompletionItem { | ||
924 | label: "foo(…)", | ||
925 | source_range: 35..37, | ||
926 | delete: 35..37, | ||
927 | insert: "foo(${1:xs})$0", | ||
928 | kind: Function, | ||
929 | lookup: "foo", | ||
930 | detail: "fn foo(xs: Ve)", | ||
931 | trigger_call_info: true, | ||
932 | }, | ||
933 | ] | ||
934 | "### | ||
935 | ); | 879 | ); |
936 | assert_debug_snapshot!( | 880 | check_edit( |
937 | do_reference_completion( | 881 | "Vec", |
938 | r" | 882 | r#" |
939 | struct Vec<T> {} | 883 | struct Vec<T> {} |
940 | fn foo(xs: Ve<|><i128>) | 884 | fn foo(xs: Ve<|><i128>) |
941 | " | 885 | "#, |
942 | ), | 886 | r#" |
943 | @r###" | 887 | struct Vec<T> {} |
944 | [ | 888 | fn foo(xs: Vec<i128>) |
945 | CompletionItem { | 889 | "#, |
946 | label: "Vec", | ||
947 | source_range: 28..30, | ||
948 | delete: 28..30, | ||
949 | insert: "Vec", | ||
950 | kind: Struct, | ||
951 | }, | ||
952 | CompletionItem { | ||
953 | label: "foo(…)", | ||
954 | source_range: 28..30, | ||
955 | delete: 28..30, | ||
956 | insert: "foo(${1:xs})$0", | ||
957 | kind: Function, | ||
958 | lookup: "foo", | ||
959 | detail: "fn foo(xs: Ve<i128>)", | ||
960 | trigger_call_info: true, | ||
961 | }, | ||
962 | ] | ||
963 | "### | ||
964 | ); | 890 | ); |
965 | } | 891 | } |
966 | 892 | ||
967 | #[test] | 893 | #[test] |
968 | fn dont_insert_macro_call_parens_unncessary() { | 894 | fn dont_insert_macro_call_parens_unncessary() { |
969 | mark::check!(dont_insert_macro_call_parens_unncessary); | 895 | mark::check!(dont_insert_macro_call_parens_unncessary); |
970 | assert_debug_snapshot!( | 896 | check_edit( |
971 | do_reference_completion( | 897 | "frobnicate!", |
972 | r" | 898 | r#" |
973 | //- /main.rs | 899 | //- /main.rs |
974 | use foo::<|>; | 900 | use foo::<|>; |
975 | 901 | //- /foo/lib.rs | |
976 | //- /foo/lib.rs | 902 | #[macro_export] |
977 | #[macro_export] | 903 | macro_rules frobnicate { () => () } |
978 | macro_rules frobnicate { | 904 | "#, |
979 | () => () | 905 | r#" |
980 | } | 906 | use foo::frobnicate; |
981 | " | 907 | "#, |
982 | ), | ||
983 | @r###" | ||
984 | [ | ||
985 | CompletionItem { | ||
986 | label: "frobnicate!", | ||
987 | source_range: 9..9, | ||
988 | delete: 9..9, | ||
989 | insert: "frobnicate", | ||
990 | kind: Macro, | ||
991 | detail: "#[macro_export]\nmacro_rules! frobnicate", | ||
992 | }, | ||
993 | ] | ||
994 | "### | ||
995 | ); | 908 | ); |
996 | 909 | ||
997 | assert_debug_snapshot!( | 910 | check_edit( |
998 | do_reference_completion( | 911 | "frobnicate!", |
999 | r" | 912 | r#" |
1000 | //- /main.rs | 913 | macro_rules frobnicate { () => () } |
1001 | macro_rules frobnicate { | 914 | fn main() { frob<|>!(); } |
1002 | () => () | 915 | "#, |
1003 | } | 916 | r#" |
1004 | fn main() { | 917 | macro_rules frobnicate { () => () } |
1005 | frob<|>!(); | 918 | fn main() { frobnicate!(); } |
1006 | } | 919 | "#, |
1007 | " | ||
1008 | ), | ||
1009 | @r###" | ||
1010 | [ | ||
1011 | CompletionItem { | ||
1012 | label: "frobnicate!", | ||
1013 | source_range: 56..60, | ||
1014 | delete: 56..60, | ||
1015 | insert: "frobnicate", | ||
1016 | kind: Macro, | ||
1017 | detail: "macro_rules! frobnicate", | ||
1018 | }, | ||
1019 | CompletionItem { | ||
1020 | label: "main()", | ||
1021 | source_range: 56..60, | ||
1022 | delete: 56..60, | ||
1023 | insert: "main()$0", | ||
1024 | kind: Function, | ||
1025 | lookup: "main", | ||
1026 | detail: "fn main()", | ||
1027 | }, | ||
1028 | ] | ||
1029 | "### | ||
1030 | ); | 920 | ); |
1031 | } | 921 | } |
1032 | 922 | ||