aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-24 00:25:54 +0100
committerAleksey Kladov <[email protected]>2020-04-24 00:26:27 +0100
commit4b8e9d5483005844e711e2f6191274c3c6ae1c4a (patch)
treee08cdee722389ccbb59749ff5f629ad6265e4208 /crates/ra_ide
parent174952e89b891b20ea580f37e34389467fb9e23c (diff)
Move tests to where they belong
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/completion/complete_dot.rs231
-rw-r--r--crates/ra_ide/src/completion/presentation.rs231
2 files changed, 231 insertions, 231 deletions
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs
index 44288f92e..b93153b48 100644
--- a/crates/ra_ide/src/completion/complete_dot.rs
+++ b/crates/ra_ide/src/completion/complete_dot.rs
@@ -106,237 +106,6 @@ mod tests {
106 } 106 }
107 107
108 #[test] 108 #[test]
109 fn test_struct_field_completion_in_func_call() {
110 assert_debug_snapshot!(
111 do_ref_completion(
112 r"
113 struct A { another_field: i64, the_field: u32, my_string: String }
114 fn test(my_param: u32) -> u32 { my_param }
115 fn foo(a: A) {
116 test(a.<|>)
117 }
118 ",
119 ),
120 @r###"
121 [
122 CompletionItem {
123 label: "another_field",
124 source_range: [201; 201),
125 delete: [201; 201),
126 insert: "another_field",
127 kind: Field,
128 detail: "i64",
129 },
130 CompletionItem {
131 label: "my_string",
132 source_range: [201; 201),
133 delete: [201; 201),
134 insert: "my_string",
135 kind: Field,
136 detail: "{unknown}",
137 },
138 CompletionItem {
139 label: "the_field",
140 source_range: [201; 201),
141 delete: [201; 201),
142 insert: "the_field",
143 kind: Field,
144 detail: "u32",
145 score: TypeMatch,
146 },
147 ]
148 "###
149 );
150 }
151
152 #[test]
153 fn test_struct_field_completion_in_func_call_with_type_and_name() {
154 assert_debug_snapshot!(
155 do_ref_completion(
156 r"
157 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
158 fn test(the_field: u32) -> u32 { the_field }
159 fn foo(a: A) {
160 test(a.<|>)
161 }
162 ",
163 ),
164 @r###"
165 [
166 CompletionItem {
167 label: "another_field",
168 source_range: [208; 208),
169 delete: [208; 208),
170 insert: "another_field",
171 kind: Field,
172 detail: "i64",
173 },
174 CompletionItem {
175 label: "another_good_type",
176 source_range: [208; 208),
177 delete: [208; 208),
178 insert: "another_good_type",
179 kind: Field,
180 detail: "u32",
181 score: TypeMatch,
182 },
183 CompletionItem {
184 label: "the_field",
185 source_range: [208; 208),
186 delete: [208; 208),
187 insert: "the_field",
188 kind: Field,
189 detail: "u32",
190 score: TypeAndNameMatch,
191 },
192 ]
193 "###
194 );
195 }
196
197 #[test]
198 fn test_struct_field_completion_in_record_lit() {
199 assert_debug_snapshot!(
200 do_ref_completion(
201 r"
202 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
203 struct B { my_string: String, my_vec: Vec<u32>, the_field: u32 }
204 fn foo(a: A) {
205 let b = B {
206 the_field: a.<|>
207 };
208 }
209 ",
210 ),
211 @r###"
212 [
213 CompletionItem {
214 label: "another_field",
215 source_range: [270; 270),
216 delete: [270; 270),
217 insert: "another_field",
218 kind: Field,
219 detail: "i64",
220 },
221 CompletionItem {
222 label: "another_good_type",
223 source_range: [270; 270),
224 delete: [270; 270),
225 insert: "another_good_type",
226 kind: Field,
227 detail: "u32",
228 score: TypeMatch,
229 },
230 CompletionItem {
231 label: "the_field",
232 source_range: [270; 270),
233 delete: [270; 270),
234 insert: "the_field",
235 kind: Field,
236 detail: "u32",
237 score: TypeAndNameMatch,
238 },
239 ]
240 "###
241 );
242 }
243
244 #[test]
245 fn test_struct_field_completion_in_record_lit_and_fn_call() {
246 assert_debug_snapshot!(
247 do_ref_completion(
248 r"
249 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
250 struct B { my_string: String, my_vec: Vec<u32>, the_field: u32 }
251 fn test(the_field: i64) -> i64 { the_field }
252 fn foo(a: A) {
253 let b = B {
254 the_field: test(a.<|>)
255 };
256 }
257 ",
258 ),
259 @r###"
260 [
261 CompletionItem {
262 label: "another_field",
263 source_range: [336; 336),
264 delete: [336; 336),
265 insert: "another_field",
266 kind: Field,
267 detail: "i64",
268 score: TypeMatch,
269 },
270 CompletionItem {
271 label: "another_good_type",
272 source_range: [336; 336),
273 delete: [336; 336),
274 insert: "another_good_type",
275 kind: Field,
276 detail: "u32",
277 },
278 CompletionItem {
279 label: "the_field",
280 source_range: [336; 336),
281 delete: [336; 336),
282 insert: "the_field",
283 kind: Field,
284 detail: "u32",
285 },
286 ]
287 "###
288 );
289 }
290
291 #[test]
292 fn test_struct_field_completion_in_fn_call_and_record_lit() {
293 assert_debug_snapshot!(
294 do_ref_completion(
295 r"
296 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
297 struct B { my_string: String, my_vec: Vec<u32>, the_field: u32 }
298 fn test(the_field: i64) -> i64 { the_field }
299 fn foo(a: A) {
300 test(B {
301 the_field: a.<|>
302 });
303 }
304 ",
305 ),
306 @r###"
307 [
308 CompletionItem {
309 label: "another_field",
310 source_range: [328; 328),
311 delete: [328; 328),
312 insert: "another_field",
313 kind: Field,
314 detail: "i64",
315 },
316 CompletionItem {
317 label: "another_good_type",
318 source_range: [328; 328),
319 delete: [328; 328),
320 insert: "another_good_type",
321 kind: Field,
322 detail: "u32",
323 score: TypeMatch,
324 },
325 CompletionItem {
326 label: "the_field",
327 source_range: [328; 328),
328 delete: [328; 328),
329 insert: "the_field",
330 kind: Field,
331 detail: "u32",
332 score: TypeAndNameMatch,
333 },
334 ]
335 "###
336 );
337 }
338
339 #[test]
340 fn test_struct_field_completion_self() { 109 fn test_struct_field_completion_self() {
341 assert_debug_snapshot!( 110 assert_debug_snapshot!(
342 do_ref_completion( 111 do_ref_completion(
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index ab43d2a0a..ae15f91de 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -1070,4 +1070,235 @@ mod tests {
1070 "### 1070 "###
1071 ); 1071 );
1072 } 1072 }
1073
1074 #[test]
1075 fn test_struct_field_completion_in_func_call() {
1076 assert_debug_snapshot!(
1077 do_reference_completion(
1078 r"
1079 struct A { another_field: i64, the_field: u32, my_string: String }
1080 fn test(my_param: u32) -> u32 { my_param }
1081 fn foo(a: A) {
1082 test(a.<|>)
1083 }
1084 ",
1085 ),
1086 @r###"
1087 [
1088 CompletionItem {
1089 label: "another_field",
1090 source_range: [201; 201),
1091 delete: [201; 201),
1092 insert: "another_field",
1093 kind: Field,
1094 detail: "i64",
1095 },
1096 CompletionItem {
1097 label: "my_string",
1098 source_range: [201; 201),
1099 delete: [201; 201),
1100 insert: "my_string",
1101 kind: Field,
1102 detail: "{unknown}",
1103 },
1104 CompletionItem {
1105 label: "the_field",
1106 source_range: [201; 201),
1107 delete: [201; 201),
1108 insert: "the_field",
1109 kind: Field,
1110 detail: "u32",
1111 score: TypeMatch,
1112 },
1113 ]
1114 "###
1115 );
1116 }
1117
1118 #[test]
1119 fn test_struct_field_completion_in_func_call_with_type_and_name() {
1120 assert_debug_snapshot!(
1121 do_reference_completion(
1122 r"
1123 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
1124 fn test(the_field: u32) -> u32 { the_field }
1125 fn foo(a: A) {
1126 test(a.<|>)
1127 }
1128 ",
1129 ),
1130 @r###"
1131 [
1132 CompletionItem {
1133 label: "another_field",
1134 source_range: [208; 208),
1135 delete: [208; 208),
1136 insert: "another_field",
1137 kind: Field,
1138 detail: "i64",
1139 },
1140 CompletionItem {
1141 label: "another_good_type",
1142 source_range: [208; 208),
1143 delete: [208; 208),
1144 insert: "another_good_type",
1145 kind: Field,
1146 detail: "u32",
1147 score: TypeMatch,
1148 },
1149 CompletionItem {
1150 label: "the_field",
1151 source_range: [208; 208),
1152 delete: [208; 208),
1153 insert: "the_field",
1154 kind: Field,
1155 detail: "u32",
1156 score: TypeAndNameMatch,
1157 },
1158 ]
1159 "###
1160 );
1161 }
1162
1163 #[test]
1164 fn test_struct_field_completion_in_record_lit() {
1165 assert_debug_snapshot!(
1166 do_reference_completion(
1167 r"
1168 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
1169 struct B { my_string: String, my_vec: Vec<u32>, the_field: u32 }
1170 fn foo(a: A) {
1171 let b = B {
1172 the_field: a.<|>
1173 };
1174 }
1175 ",
1176 ),
1177 @r###"
1178 [
1179 CompletionItem {
1180 label: "another_field",
1181 source_range: [270; 270),
1182 delete: [270; 270),
1183 insert: "another_field",
1184 kind: Field,
1185 detail: "i64",
1186 },
1187 CompletionItem {
1188 label: "another_good_type",
1189 source_range: [270; 270),
1190 delete: [270; 270),
1191 insert: "another_good_type",
1192 kind: Field,
1193 detail: "u32",
1194 score: TypeMatch,
1195 },
1196 CompletionItem {
1197 label: "the_field",
1198 source_range: [270; 270),
1199 delete: [270; 270),
1200 insert: "the_field",
1201 kind: Field,
1202 detail: "u32",
1203 score: TypeAndNameMatch,
1204 },
1205 ]
1206 "###
1207 );
1208 }
1209
1210 #[test]
1211 fn test_struct_field_completion_in_record_lit_and_fn_call() {
1212 assert_debug_snapshot!(
1213 do_reference_completion(
1214 r"
1215 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
1216 struct B { my_string: String, my_vec: Vec<u32>, the_field: u32 }
1217 fn test(the_field: i64) -> i64 { the_field }
1218 fn foo(a: A) {
1219 let b = B {
1220 the_field: test(a.<|>)
1221 };
1222 }
1223 ",
1224 ),
1225 @r###"
1226 [
1227 CompletionItem {
1228 label: "another_field",
1229 source_range: [336; 336),
1230 delete: [336; 336),
1231 insert: "another_field",
1232 kind: Field,
1233 detail: "i64",
1234 score: TypeMatch,
1235 },
1236 CompletionItem {
1237 label: "another_good_type",
1238 source_range: [336; 336),
1239 delete: [336; 336),
1240 insert: "another_good_type",
1241 kind: Field,
1242 detail: "u32",
1243 },
1244 CompletionItem {
1245 label: "the_field",
1246 source_range: [336; 336),
1247 delete: [336; 336),
1248 insert: "the_field",
1249 kind: Field,
1250 detail: "u32",
1251 },
1252 ]
1253 "###
1254 );
1255 }
1256
1257 #[test]
1258 fn test_struct_field_completion_in_fn_call_and_record_lit() {
1259 assert_debug_snapshot!(
1260 do_reference_completion(
1261 r"
1262 struct A { another_field: i64, another_good_type: u32, the_field: u32 }
1263 struct B { my_string: String, my_vec: Vec<u32>, the_field: u32 }
1264 fn test(the_field: i64) -> i64 { the_field }
1265 fn foo(a: A) {
1266 test(B {
1267 the_field: a.<|>
1268 });
1269 }
1270 ",
1271 ),
1272 @r###"
1273 [
1274 CompletionItem {
1275 label: "another_field",
1276 source_range: [328; 328),
1277 delete: [328; 328),
1278 insert: "another_field",
1279 kind: Field,
1280 detail: "i64",
1281 },
1282 CompletionItem {
1283 label: "another_good_type",
1284 source_range: [328; 328),
1285 delete: [328; 328),
1286 insert: "another_good_type",
1287 kind: Field,
1288 detail: "u32",
1289 score: TypeMatch,
1290 },
1291 CompletionItem {
1292 label: "the_field",
1293 source_range: [328; 328),
1294 delete: [328; 328),
1295 insert: "the_field",
1296 kind: Field,
1297 detail: "u32",
1298 score: TypeAndNameMatch,
1299 },
1300 ]
1301 "###
1302 );
1303 }
1073} 1304}