Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/tests/pattern.rs')
-rw-r--r--crates/ide-completion/src/tests/pattern.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/crates/ide-completion/src/tests/pattern.rs b/crates/ide-completion/src/tests/pattern.rs
index 6a0b67e291..bd3e7c72bc 100644
--- a/crates/ide-completion/src/tests/pattern.rs
+++ b/crates/ide-completion/src/tests/pattern.rs
@@ -198,6 +198,7 @@ fn foo(a$0: Tuple) {
st Unit
bn Record {…} Record { field$1 }$0
bn Tuple(…) Tuple($1)$0
+ bn tuple
kw mut
kw ref
"#]],
@@ -850,3 +851,75 @@ fn foo() {
"#,
);
}
+
+#[test]
+fn suggest_name_for_pattern() {
+ check_edit(
+ "s1",
+ r#"
+struct S1;
+
+fn foo() {
+ let $0 = S1;
+}
+"#,
+ r#"
+struct S1;
+
+fn foo() {
+ let s1 = S1;
+}
+"#,
+ );
+
+ check_edit(
+ "s1",
+ r#"
+struct S1;
+
+fn foo(s$0: S1) {
+}
+"#,
+ r#"
+struct S1;
+
+fn foo(s1: S1) {
+}
+"#,
+ );
+
+ // Tests for &adt
+ check_edit(
+ "s1",
+ r#"
+struct S1;
+
+fn foo() {
+ let $0 = &S1;
+}
+"#,
+ r#"
+struct S1;
+
+fn foo() {
+ let s1 = &S1;
+}
+"#,
+ );
+
+ // Do not suggest reserved keywords
+ check_empty(
+ r#"
+struct Struct;
+
+fn foo() {
+ let $0 = Struct;
+}
+"#,
+ expect![[r#"
+ st Struct
+ kw mut
+ kw ref
+ "#]],
+ );
+}