mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-29 11:37:39 +00:00
Add a test for correct completion of ..Default::default()
This commit is contained in:
parent
4cc3a6d4fe
commit
49eeeb61ae
@ -53,7 +53,10 @@ mod tests {
|
|||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use ide_db::helpers::FamousDefs;
|
use ide_db::helpers::FamousDefs;
|
||||||
|
|
||||||
use crate::{test_utils::completion_list, CompletionKind};
|
use crate::{
|
||||||
|
test_utils::{self, completion_list},
|
||||||
|
CompletionKind,
|
||||||
|
};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
fn check(ra_fixture: &str, expect: Expect) {
|
||||||
let actual = completion_list(ra_fixture, CompletionKind::Reference);
|
let actual = completion_list(ra_fixture, CompletionKind::Reference);
|
||||||
@ -68,6 +71,18 @@ mod tests {
|
|||||||
expect.assert_eq(&actual);
|
expect.assert_eq(&actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) {
|
||||||
|
test_utils::check_edit(
|
||||||
|
what,
|
||||||
|
&format!(
|
||||||
|
"//- /main.rs crate:main deps:core{}\n{}",
|
||||||
|
ra_fixture_before,
|
||||||
|
FamousDefs::FIXTURE,
|
||||||
|
),
|
||||||
|
&(ra_fixture_after.to_owned() + "\n"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_record_literal_field_default() {
|
fn test_record_literal_field_default() {
|
||||||
let test_code = r#"
|
let test_code = r#"
|
||||||
@ -106,6 +121,51 @@ fn process(f: S) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_record_literal_field_default_completion() {
|
||||||
|
check_edit(
|
||||||
|
"..Default::default()",
|
||||||
|
r#"
|
||||||
|
struct S { foo: u32, bar: usize }
|
||||||
|
|
||||||
|
impl core::default::Default for S {
|
||||||
|
fn default() -> Self {
|
||||||
|
S {
|
||||||
|
foo: 0,
|
||||||
|
bar: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process(f: S) {
|
||||||
|
let other = S {
|
||||||
|
foo: 5,
|
||||||
|
.<|>
|
||||||
|
};
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
struct S { foo: u32, bar: usize }
|
||||||
|
|
||||||
|
impl core::default::Default for S {
|
||||||
|
fn default() -> Self {
|
||||||
|
S {
|
||||||
|
foo: 0,
|
||||||
|
bar: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process(f: S) {
|
||||||
|
let other = S {
|
||||||
|
foo: 5,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_record_literal_field_without_default() {
|
fn test_record_literal_field_without_default() {
|
||||||
let test_code = r#"
|
let test_code = r#"
|
||||||
|
Loading…
Reference in New Issue
Block a user