Skip to content

Commit

Permalink
tests: suggesting names in completions for let_stmt and fn_param
Browse files Browse the repository at this point in the history
  • Loading branch information
roife committed Sep 2, 2024
1 parent 492e66c commit 35ed65a
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions crates/ide-completion/src/tests/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"#]],
Expand Down Expand Up @@ -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
"#]],
);
}

0 comments on commit 35ed65a

Please sign in to comment.