aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-16 18:25:09 +0100
committerLukas Wirth <[email protected]>2021-06-16 18:25:09 +0100
commit8f936c557162d66a451f10481ff726a37b27302e (patch)
tree2b5c4d8cd46fbde6eeb4fa0cc285f71c013e98ac /crates/ide_completion
parent1c034c084d79f20c5208208a891f38bf582433e6 (diff)
Add builtin derives to attribute completion fixtures
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/completions/attribute/derive.rs74
1 files changed, 67 insertions, 7 deletions
diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs
index 7b3133e53..c59add6c5 100644
--- a/crates/ide_completion/src/completions/attribute/derive.rs
+++ b/crates/ide_completion/src/completions/attribute/derive.rs
@@ -83,7 +83,31 @@ mod tests {
83 use crate::{test_utils::completion_list, CompletionKind}; 83 use crate::{test_utils::completion_list, CompletionKind};
84 84
85 fn check(ra_fixture: &str, expect: Expect) { 85 fn check(ra_fixture: &str, expect: Expect) {
86 let actual = completion_list(ra_fixture, CompletionKind::Attribute); 86 let builtin_derives = r#"
87#[rustc_builtin_macro]
88pub macro Clone {}
89#[rustc_builtin_macro]
90pub macro Copy {}
91#[rustc_builtin_macro]
92pub macro Default {}
93#[rustc_builtin_macro]
94pub macro Debug {}
95#[rustc_builtin_macro]
96pub macro Hash {}
97#[rustc_builtin_macro]
98pub macro PartialEq {}
99#[rustc_builtin_macro]
100pub macro Eq {}
101#[rustc_builtin_macro]
102pub macro PartialOrd {}
103#[rustc_builtin_macro]
104pub macro Ord {}
105
106"#;
107 let actual = completion_list(
108 &format!("{} {}", builtin_derives, ra_fixture),
109 CompletionKind::Attribute,
110 );
87 expect.assert_eq(&actual); 111 expect.assert_eq(&actual);
88 } 112 }
89 113
@@ -94,19 +118,55 @@ mod tests {
94 118
95 #[test] 119 #[test]
96 fn empty_derive() { 120 fn empty_derive() {
97 // FIXME: Add build-in derives to fixture. 121 check(
98 check(r#"#[derive($0)] struct Test;"#, expect![[r#""#]]); 122 r#"#[derive($0)] struct Test;"#,
123 expect![[r#"
124 at PartialEq
125 at Default
126 at PartialEq, Eq
127 at PartialEq, Eq, PartialOrd, Ord
128 at Clone, Copy
129 at Debug
130 at Clone
131 at Hash
132 at PartialEq, PartialOrd
133 "#]],
134 );
99 } 135 }
100 136
101 #[test] 137 #[test]
102 fn derive_with_input() { 138 fn derive_with_input() {
103 // FIXME: Add build-in derives to fixture. 139 check(
104 check(r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, expect![[r#""#]]) 140 r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#,
141 expect![[r#"
142 at PartialEq
143 at Default
144 at Eq
145 at Eq, PartialOrd, Ord
146 at Clone, Copy
147 at Debug
148 at Clone
149 at Hash
150 at PartialOrd
151 "#]],
152 )
105 } 153 }
106 154
107 #[test] 155 #[test]
108 fn derive_with_input2() { 156 fn derive_with_input2() {
109 // FIXME: Add build-in derives to fixture. 157 check(
110 check(r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, expect![[r#""#]]) 158 r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#,
159 expect![[r#"
160 at PartialEq
161 at Default
162 at Eq
163 at Eq, PartialOrd, Ord
164 at Clone, Copy
165 at Debug
166 at Clone
167 at Hash
168 at PartialOrd
169 "#]],
170 )
111 } 171 }
112} 172}