aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/record.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/record.rs')
-rw-r--r--crates/ide_completion/src/completions/record.rs28
1 files changed, 7 insertions, 21 deletions
diff --git a/crates/ide_completion/src/completions/record.rs b/crates/ide_completion/src/completions/record.rs
index 47523f72f..e876337f1 100644
--- a/crates/ide_completion/src/completions/record.rs
+++ b/crates/ide_completion/src/completions/record.rs
@@ -48,10 +48,9 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
48#[cfg(test)] 48#[cfg(test)]
49mod tests { 49mod tests {
50 use expect_test::{expect, Expect}; 50 use expect_test::{expect, Expect};
51 use ide_db::helpers::FamousDefs;
52 51
53 use crate::{ 52 use crate::{
54 tests::{self, filtered_completion_list}, 53 tests::{check_edit, filtered_completion_list},
55 CompletionKind, 54 CompletionKind,
56 }; 55 };
57 56
@@ -61,31 +60,17 @@ mod tests {
61 } 60 }
62 61
63 fn check_snippet(ra_fixture: &str, expect: Expect) { 62 fn check_snippet(ra_fixture: &str, expect: Expect) {
64 let actual = filtered_completion_list( 63 let actual = filtered_completion_list(ra_fixture, CompletionKind::Snippet);
65 &format!("//- /main.rs crate:main deps:core\n{}\n{}", ra_fixture, FamousDefs::FIXTURE),
66 CompletionKind::Snippet,
67 );
68 expect.assert_eq(&actual); 64 expect.assert_eq(&actual);
69 } 65 }
70 66
71 fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) {
72 tests::check_edit(
73 what,
74 &format!(
75 "//- /main.rs crate:main deps:core{}\n{}",
76 ra_fixture_before,
77 FamousDefs::FIXTURE,
78 ),
79 &(ra_fixture_after.to_owned() + "\n"),
80 );
81 }
82
83 #[test] 67 #[test]
84 fn test_record_literal_field_default() { 68 fn test_record_literal_field_default() {
85 let test_code = r#" 69 let test_code = r#"
70//- minicore: default
86struct S { foo: u32, bar: usize } 71struct S { foo: u32, bar: usize }
87 72
88impl core::default::Default for S { 73impl Default for S {
89 fn default() -> Self { 74 fn default() -> Self {
90 S { 75 S {
91 foo: 0, 76 foo: 0,
@@ -121,9 +106,10 @@ fn process(f: S) {
121 check_edit( 106 check_edit(
122 "..Default::default()", 107 "..Default::default()",
123 r#" 108 r#"
109//- minicore: default
124struct S { foo: u32, bar: usize } 110struct S { foo: u32, bar: usize }
125 111
126impl core::default::Default for S { 112impl Default for S {
127 fn default() -> Self { 113 fn default() -> Self {
128 S { 114 S {
129 foo: 0, 115 foo: 0,
@@ -142,7 +128,7 @@ fn process(f: S) {
142 r#" 128 r#"
143struct S { foo: u32, bar: usize } 129struct S { foo: u32, bar: usize }
144 130
145impl core::default::Default for S { 131impl Default for S {
146 fn default() -> Self { 132 fn default() -> Self {
147 S { 133 S {
148 foo: 0, 134 foo: 0,