diff options
Diffstat (limited to 'crates/ide_completion/src/render.rs')
-rw-r--r-- | crates/ide_completion/src/render.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index 670563e50..2514dda7c 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs | |||
@@ -928,6 +928,66 @@ fn f(foo: &Foo) { f(foo, w$0) } | |||
928 | } | 928 | } |
929 | 929 | ||
930 | #[test] | 930 | #[test] |
931 | fn score_fn_type_and_name_match() { | ||
932 | check_relevance( | ||
933 | r#" | ||
934 | struct A { bar: u8 } | ||
935 | fn baz() -> u8 { 0 } | ||
936 | fn bar() -> u8 { 0 } | ||
937 | fn f() { A { bar: b$0 }; } | ||
938 | "#, | ||
939 | expect![[r#" | ||
940 | fn baz() [type] | ||
941 | st A [] | ||
942 | fn bar() [type+name] | ||
943 | fn f() [] | ||
944 | "#]], | ||
945 | ); | ||
946 | } | ||
947 | |||
948 | #[test] | ||
949 | fn score_method_type_and_name_match() { | ||
950 | check_relevance( | ||
951 | r#" | ||
952 | fn baz(aaa: u32){} | ||
953 | struct Foo; | ||
954 | impl Foo { | ||
955 | fn aaa(&self) -> u32 { 0 } | ||
956 | fn bbb(&self) -> u32 { 0 } | ||
957 | fn ccc(&self) -> u64 { 0 } | ||
958 | } | ||
959 | fn f() { | ||
960 | baz(Foo.$0 | ||
961 | } | ||
962 | "#, | ||
963 | expect![[r#" | ||
964 | me aaa() [type+name] | ||
965 | me bbb() [type] | ||
966 | me ccc() [] | ||
967 | "#]], | ||
968 | ); | ||
969 | } | ||
970 | |||
971 | #[test] | ||
972 | fn score_method_name_match_only() { | ||
973 | check_relevance( | ||
974 | r#" | ||
975 | fn baz(aaa: u32){} | ||
976 | struct Foo; | ||
977 | impl Foo { | ||
978 | fn aaa(&self) -> u64 { 0 } | ||
979 | } | ||
980 | fn f() { | ||
981 | baz(Foo.$0 | ||
982 | } | ||
983 | "#, | ||
984 | expect![[r#" | ||
985 | me aaa() [name] | ||
986 | "#]], | ||
987 | ); | ||
988 | } | ||
989 | |||
990 | #[test] | ||
931 | fn suggest_ref_mut() { | 991 | fn suggest_ref_mut() { |
932 | cov_mark::check!(suggest_ref); | 992 | cov_mark::check!(suggest_ref); |
933 | check( | 993 | check( |