add tests for tuple fields and expect fn type cases

This commit is contained in:
dfireBird 2023-11-15 21:46:30 +05:30
parent eedeb58a4e
commit aa1cf8d357
No known key found for this signature in database
GPG key ID: 26D522CA5FC2B93D
2 changed files with 72 additions and 0 deletions

View file

@ -1219,4 +1219,20 @@ fn foo() { S { field: || {} }.fi$0() }
"#]], "#]],
); );
} }
#[test]
fn test_tuple_function_field_completion() {
check(
r#"
struct B(u32, fn())
fn foo() {
let b = B(0, || {});
b.$0()
}
"#,
expect![[r#"
fd 1 fn()
"#]],
);
}
} }

View file

@ -1690,6 +1690,62 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 }
); );
} }
#[test]
fn expected_fn_type_ref() {
check_kinds(
r#"
struct S { field: fn() }
fn foo() {
let foo: fn() = S { fields: || {}}.fi$0;
}
"#,
&[CompletionItemKind::SymbolKind(SymbolKind::Field)],
expect![[r#"
[
CompletionItem {
label: "field",
source_range: 76..78,
text_edit: TextEdit {
indels: [
Indel {
insert: "(",
delete: 57..57,
},
Indel {
insert: ")",
delete: 75..75,
},
Indel {
insert: "field",
delete: 76..78,
},
],
},
kind: SymbolKind(
Field,
),
detail: "fn()",
relevance: CompletionRelevance {
exact_name_match: false,
type_match: Some(
Exact,
),
is_local: false,
is_item_from_trait: false,
is_name_already_imported: false,
requires_import: false,
is_op_method: false,
is_private_editable: false,
postfix_match: None,
is_definite: false,
},
},
]
"#]],
)
}
#[test] #[test]
fn qualified_path_ref() { fn qualified_path_ref() {
check_kinds( check_kinds(