diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-07 10:45:09 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-07 10:45:09 +0000 |
commit | 1b147306b47bb869a048c510f40083387d4dfe27 (patch) | |
tree | f9e1f9805a3fea9e0d58a25b29ed6a2118081f16 /crates/assists | |
parent | fa03bfb115f49a681fb1ea6a9ea1209c847ac0be (diff) | |
parent | 69ba62e6cd5d3a637477310522acef6e599197fb (diff) |
Merge #6490
6490: Minimize convert_integer_literal tests r=matklad a=m-ysk
Closes #6455
This PR removes some redundant tests around convert_integer_literal.
First, it removes test cases about converting integer with underscores except for just one case. This is because the process of removing of underscores in given integer literals is independent from radix.
Second, as well as underscore cases, it removes test cases about converting integer with suffix except for just one case. This is because the process of handling suffix is independent from radix.
Finally, it removes small decimal integer cases. This is because "special case where they return early" has been removed by the PR #6482, so we have no need to retain this cases.
Co-authored-by: m-ysk <[email protected]>
Diffstat (limited to 'crates/assists')
-rw-r--r-- | crates/assists/src/handlers/convert_integer_literal.rs | 370 |
1 files changed, 2 insertions, 368 deletions
diff --git a/crates/assists/src/handlers/convert_integer_literal.rs b/crates/assists/src/handlers/convert_integer_literal.rs index 1094ed3f3..667115382 100644 --- a/crates/assists/src/handlers/convert_integer_literal.rs +++ b/crates/assists/src/handlers/convert_integer_literal.rs | |||
@@ -129,34 +129,6 @@ mod tests { | |||
129 | ); | 129 | ); |
130 | } | 130 | } |
131 | 131 | ||
132 | // Decimal numbers under 3 digits have a special case where they return early because we can't fit a | ||
133 | // other base's prefix, so we have a separate test for that. | ||
134 | #[test] | ||
135 | fn convert_small_decimal_integer() { | ||
136 | let before = "const _: i32 = 10<|>;"; | ||
137 | |||
138 | check_assist_by_label( | ||
139 | convert_integer_literal, | ||
140 | before, | ||
141 | "const _: i32 = 0b1010;", | ||
142 | "Convert 10 to 0b1010", | ||
143 | ); | ||
144 | |||
145 | check_assist_by_label( | ||
146 | convert_integer_literal, | ||
147 | before, | ||
148 | "const _: i32 = 0o12;", | ||
149 | "Convert 10 to 0o12", | ||
150 | ); | ||
151 | |||
152 | check_assist_by_label( | ||
153 | convert_integer_literal, | ||
154 | before, | ||
155 | "const _: i32 = 0xA;", | ||
156 | "Convert 10 to 0xA", | ||
157 | ); | ||
158 | } | ||
159 | |||
160 | #[test] | 132 | #[test] |
161 | fn convert_hexadecimal_integer() { | 133 | fn convert_hexadecimal_integer() { |
162 | let before = "const _: i32 = 0xFF<|>;"; | 134 | let before = "const _: i32 = 0xFF<|>;"; |
@@ -236,7 +208,7 @@ mod tests { | |||
236 | } | 208 | } |
237 | 209 | ||
238 | #[test] | 210 | #[test] |
239 | fn convert_decimal_integer_with_underscores() { | 211 | fn convert_integer_with_underscores() { |
240 | let before = "const _: i32 = 1_00_0<|>;"; | 212 | let before = "const _: i32 = 1_00_0<|>;"; |
241 | 213 | ||
242 | check_assist_by_label( | 214 | check_assist_by_label( |
@@ -262,111 +234,7 @@ mod tests { | |||
262 | } | 234 | } |
263 | 235 | ||
264 | #[test] | 236 | #[test] |
265 | fn convert_small_decimal_integer_with_underscores() { | 237 | fn convert_integer_with_suffix() { |
266 | let before = "const _: i32 = 1_0<|>;"; | ||
267 | |||
268 | check_assist_by_label( | ||
269 | convert_integer_literal, | ||
270 | before, | ||
271 | "const _: i32 = 0b1010;", | ||
272 | "Convert 1_0 to 0b1010", | ||
273 | ); | ||
274 | |||
275 | check_assist_by_label( | ||
276 | convert_integer_literal, | ||
277 | before, | ||
278 | "const _: i32 = 0o12;", | ||
279 | "Convert 1_0 to 0o12", | ||
280 | ); | ||
281 | |||
282 | check_assist_by_label( | ||
283 | convert_integer_literal, | ||
284 | before, | ||
285 | "const _: i32 = 0xA;", | ||
286 | "Convert 1_0 to 0xA", | ||
287 | ); | ||
288 | } | ||
289 | |||
290 | #[test] | ||
291 | fn convert_hexadecimal_integer_with_underscores() { | ||
292 | let before = "const _: i32 = 0x_F_F<|>;"; | ||
293 | |||
294 | check_assist_by_label( | ||
295 | convert_integer_literal, | ||
296 | before, | ||
297 | "const _: i32 = 0b11111111;", | ||
298 | "Convert 0x_F_F to 0b11111111", | ||
299 | ); | ||
300 | |||
301 | check_assist_by_label( | ||
302 | convert_integer_literal, | ||
303 | before, | ||
304 | "const _: i32 = 0o377;", | ||
305 | "Convert 0x_F_F to 0o377", | ||
306 | ); | ||
307 | |||
308 | check_assist_by_label( | ||
309 | convert_integer_literal, | ||
310 | before, | ||
311 | "const _: i32 = 255;", | ||
312 | "Convert 0x_F_F to 255", | ||
313 | ); | ||
314 | } | ||
315 | |||
316 | #[test] | ||
317 | fn convert_binary_integer_with_underscores() { | ||
318 | let before = "const _: i32 = 0b1111_1111<|>;"; | ||
319 | |||
320 | check_assist_by_label( | ||
321 | convert_integer_literal, | ||
322 | before, | ||
323 | "const _: i32 = 0o377;", | ||
324 | "Convert 0b1111_1111 to 0o377", | ||
325 | ); | ||
326 | |||
327 | check_assist_by_label( | ||
328 | convert_integer_literal, | ||
329 | before, | ||
330 | "const _: i32 = 255;", | ||
331 | "Convert 0b1111_1111 to 255", | ||
332 | ); | ||
333 | |||
334 | check_assist_by_label( | ||
335 | convert_integer_literal, | ||
336 | before, | ||
337 | "const _: i32 = 0xFF;", | ||
338 | "Convert 0b1111_1111 to 0xFF", | ||
339 | ); | ||
340 | } | ||
341 | |||
342 | #[test] | ||
343 | fn convert_octal_integer_with_underscores() { | ||
344 | let before = "const _: i32 = 0o3_77<|>;"; | ||
345 | |||
346 | check_assist_by_label( | ||
347 | convert_integer_literal, | ||
348 | before, | ||
349 | "const _: i32 = 0b11111111;", | ||
350 | "Convert 0o3_77 to 0b11111111", | ||
351 | ); | ||
352 | |||
353 | check_assist_by_label( | ||
354 | convert_integer_literal, | ||
355 | before, | ||
356 | "const _: i32 = 255;", | ||
357 | "Convert 0o3_77 to 255", | ||
358 | ); | ||
359 | |||
360 | check_assist_by_label( | ||
361 | convert_integer_literal, | ||
362 | before, | ||
363 | "const _: i32 = 0xFF;", | ||
364 | "Convert 0o3_77 to 0xFF", | ||
365 | ); | ||
366 | } | ||
367 | |||
368 | #[test] | ||
369 | fn convert_decimal_integer_with_suffix() { | ||
370 | let before = "const _: i32 = 1000i32<|>;"; | 238 | let before = "const _: i32 = 1000i32<|>;"; |
371 | 239 | ||
372 | check_assist_by_label( | 240 | check_assist_by_label( |
@@ -392,240 +260,6 @@ mod tests { | |||
392 | } | 260 | } |
393 | 261 | ||
394 | #[test] | 262 | #[test] |
395 | fn convert_small_decimal_integer_with_suffix() { | ||
396 | let before = "const _: i32 = 10i32<|>;"; | ||
397 | |||
398 | check_assist_by_label( | ||
399 | convert_integer_literal, | ||
400 | before, | ||
401 | "const _: i32 = 0b1010i32;", | ||
402 | "Convert 10i32 to 0b1010i32", | ||
403 | ); | ||
404 | |||
405 | check_assist_by_label( | ||
406 | convert_integer_literal, | ||
407 | before, | ||
408 | "const _: i32 = 0o12i32;", | ||
409 | "Convert 10i32 to 0o12i32", | ||
410 | ); | ||
411 | |||
412 | check_assist_by_label( | ||
413 | convert_integer_literal, | ||
414 | before, | ||
415 | "const _: i32 = 0xAi32;", | ||
416 | "Convert 10i32 to 0xAi32", | ||
417 | ); | ||
418 | } | ||
419 | |||
420 | #[test] | ||
421 | fn convert_hexadecimal_integer_with_suffix() { | ||
422 | let before = "const _: i32 = 0xFFi32<|>;"; | ||
423 | |||
424 | check_assist_by_label( | ||
425 | convert_integer_literal, | ||
426 | before, | ||
427 | "const _: i32 = 0b11111111i32;", | ||
428 | "Convert 0xFFi32 to 0b11111111i32", | ||
429 | ); | ||
430 | |||
431 | check_assist_by_label( | ||
432 | convert_integer_literal, | ||
433 | before, | ||
434 | "const _: i32 = 0o377i32;", | ||
435 | "Convert 0xFFi32 to 0o377i32", | ||
436 | ); | ||
437 | |||
438 | check_assist_by_label( | ||
439 | convert_integer_literal, | ||
440 | before, | ||
441 | "const _: i32 = 255i32;", | ||
442 | "Convert 0xFFi32 to 255i32", | ||
443 | ); | ||
444 | } | ||
445 | |||
446 | #[test] | ||
447 | fn convert_binary_integer_with_suffix() { | ||
448 | let before = "const _: i32 = 0b11111111i32<|>;"; | ||
449 | |||
450 | check_assist_by_label( | ||
451 | convert_integer_literal, | ||
452 | before, | ||
453 | "const _: i32 = 0o377i32;", | ||
454 | "Convert 0b11111111i32 to 0o377i32", | ||
455 | ); | ||
456 | |||
457 | check_assist_by_label( | ||
458 | convert_integer_literal, | ||
459 | before, | ||
460 | "const _: i32 = 255i32;", | ||
461 | "Convert 0b11111111i32 to 255i32", | ||
462 | ); | ||
463 | |||
464 | check_assist_by_label( | ||
465 | convert_integer_literal, | ||
466 | before, | ||
467 | "const _: i32 = 0xFFi32;", | ||
468 | "Convert 0b11111111i32 to 0xFFi32", | ||
469 | ); | ||
470 | } | ||
471 | |||
472 | #[test] | ||
473 | fn convert_octal_integer_with_suffix() { | ||
474 | let before = "const _: i32 = 0o377i32<|>;"; | ||
475 | |||
476 | check_assist_by_label( | ||
477 | convert_integer_literal, | ||
478 | before, | ||
479 | "const _: i32 = 0b11111111i32;", | ||
480 | "Convert 0o377i32 to 0b11111111i32", | ||
481 | ); | ||
482 | |||
483 | check_assist_by_label( | ||
484 | convert_integer_literal, | ||
485 | before, | ||
486 | "const _: i32 = 255i32;", | ||
487 | "Convert 0o377i32 to 255i32", | ||
488 | ); | ||
489 | |||
490 | check_assist_by_label( | ||
491 | convert_integer_literal, | ||
492 | before, | ||
493 | "const _: i32 = 0xFFi32;", | ||
494 | "Convert 0o377i32 to 0xFFi32", | ||
495 | ); | ||
496 | } | ||
497 | |||
498 | #[test] | ||
499 | fn convert_decimal_integer_with_underscores_and_suffix() { | ||
500 | let before = "const _: i32 = 1_00_0i32<|>;"; | ||
501 | |||
502 | check_assist_by_label( | ||
503 | convert_integer_literal, | ||
504 | before, | ||
505 | "const _: i32 = 0b1111101000i32;", | ||
506 | "Convert 1_00_0i32 to 0b1111101000i32", | ||
507 | ); | ||
508 | |||
509 | check_assist_by_label( | ||
510 | convert_integer_literal, | ||
511 | before, | ||
512 | "const _: i32 = 0o1750i32;", | ||
513 | "Convert 1_00_0i32 to 0o1750i32", | ||
514 | ); | ||
515 | |||
516 | check_assist_by_label( | ||
517 | convert_integer_literal, | ||
518 | before, | ||
519 | "const _: i32 = 0x3E8i32;", | ||
520 | "Convert 1_00_0i32 to 0x3E8i32", | ||
521 | ); | ||
522 | } | ||
523 | |||
524 | #[test] | ||
525 | fn convert_small_decimal_integer_with_underscores_and_suffix() { | ||
526 | let before = "const _: i32 = 1_0i32<|>;"; | ||
527 | |||
528 | check_assist_by_label( | ||
529 | convert_integer_literal, | ||
530 | before, | ||
531 | "const _: i32 = 0b1010i32;", | ||
532 | "Convert 1_0i32 to 0b1010i32", | ||
533 | ); | ||
534 | |||
535 | check_assist_by_label( | ||
536 | convert_integer_literal, | ||
537 | before, | ||
538 | "const _: i32 = 0o12i32;", | ||
539 | "Convert 1_0i32 to 0o12i32", | ||
540 | ); | ||
541 | |||
542 | check_assist_by_label( | ||
543 | convert_integer_literal, | ||
544 | before, | ||
545 | "const _: i32 = 0xAi32;", | ||
546 | "Convert 1_0i32 to 0xAi32", | ||
547 | ); | ||
548 | } | ||
549 | |||
550 | #[test] | ||
551 | fn convert_hexadecimal_integer_with_underscores_and_suffix() { | ||
552 | let before = "const _: i32 = 0x_F_Fi32<|>;"; | ||
553 | |||
554 | check_assist_by_label( | ||
555 | convert_integer_literal, | ||
556 | before, | ||
557 | "const _: i32 = 0b11111111i32;", | ||
558 | "Convert 0x_F_Fi32 to 0b11111111i32", | ||
559 | ); | ||
560 | |||
561 | check_assist_by_label( | ||
562 | convert_integer_literal, | ||
563 | before, | ||
564 | "const _: i32 = 0o377i32;", | ||
565 | "Convert 0x_F_Fi32 to 0o377i32", | ||
566 | ); | ||
567 | |||
568 | check_assist_by_label( | ||
569 | convert_integer_literal, | ||
570 | before, | ||
571 | "const _: i32 = 255i32;", | ||
572 | "Convert 0x_F_Fi32 to 255i32", | ||
573 | ); | ||
574 | } | ||
575 | |||
576 | #[test] | ||
577 | fn convert_binary_integer_with_underscores_and_suffix() { | ||
578 | let before = "const _: i32 = 0b1111_1111i32<|>;"; | ||
579 | |||
580 | check_assist_by_label( | ||
581 | convert_integer_literal, | ||
582 | before, | ||
583 | "const _: i32 = 0o377i32;", | ||
584 | "Convert 0b1111_1111i32 to 0o377i32", | ||
585 | ); | ||
586 | |||
587 | check_assist_by_label( | ||
588 | convert_integer_literal, | ||
589 | before, | ||
590 | "const _: i32 = 255i32;", | ||
591 | "Convert 0b1111_1111i32 to 255i32", | ||
592 | ); | ||
593 | |||
594 | check_assist_by_label( | ||
595 | convert_integer_literal, | ||
596 | before, | ||
597 | "const _: i32 = 0xFFi32;", | ||
598 | "Convert 0b1111_1111i32 to 0xFFi32", | ||
599 | ); | ||
600 | } | ||
601 | |||
602 | #[test] | ||
603 | fn convert_octal_integer_with_underscores_and_suffix() { | ||
604 | let before = "const _: i32 = 0o3_77i32<|>;"; | ||
605 | |||
606 | check_assist_by_label( | ||
607 | convert_integer_literal, | ||
608 | before, | ||
609 | "const _: i32 = 0b11111111i32;", | ||
610 | "Convert 0o3_77i32 to 0b11111111i32", | ||
611 | ); | ||
612 | |||
613 | check_assist_by_label( | ||
614 | convert_integer_literal, | ||
615 | before, | ||
616 | "const _: i32 = 255i32;", | ||
617 | "Convert 0o3_77i32 to 255i32", | ||
618 | ); | ||
619 | |||
620 | check_assist_by_label( | ||
621 | convert_integer_literal, | ||
622 | before, | ||
623 | "const _: i32 = 0xFFi32;", | ||
624 | "Convert 0o3_77i32 to 0xFFi32", | ||
625 | ); | ||
626 | } | ||
627 | |||
628 | #[test] | ||
629 | fn convert_overflowing_literal() { | 263 | fn convert_overflowing_literal() { |
630 | let before = "const _: i32 = | 264 | let before = "const _: i32 = |
631 | 111111111111111111111111111111111111111111111111111111111111111111111111<|>;"; | 265 | 111111111111111111111111111111111111111111111111111111111111111111111111<|>;"; |