diff options
Diffstat (limited to 'crates/ide_assists/src/tests')
-rw-r--r-- | crates/ide_assists/src/tests/generated.rs | 89 |
1 files changed, 85 insertions, 4 deletions
diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 0516deaff..4f007aa48 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs | |||
@@ -147,12 +147,12 @@ fn doctest_apply_demorgan() { | |||
147 | "apply_demorgan", | 147 | "apply_demorgan", |
148 | r#####" | 148 | r#####" |
149 | fn main() { | 149 | fn main() { |
150 | if x != 4 ||$0 !y {} | 150 | if x != 4 ||$0 y < 3.14 {} |
151 | } | 151 | } |
152 | "#####, | 152 | "#####, |
153 | r#####" | 153 | r#####" |
154 | fn main() { | 154 | fn main() { |
155 | if !(x == 4 && y) {} | 155 | if !(x == 4 && !(y < 3.14)) {} |
156 | } | 156 | } |
157 | "#####, | 157 | "#####, |
158 | ) | 158 | ) |
@@ -460,9 +460,38 @@ struct Point { | |||
460 | } | 460 | } |
461 | 461 | ||
462 | #[test] | 462 | #[test] |
463 | fn doctest_generate_enum_match_method() { | 463 | fn doctest_generate_enum_as_method() { |
464 | check_doc_test( | 464 | check_doc_test( |
465 | "generate_enum_match_method", | 465 | "generate_enum_as_method", |
466 | r#####" | ||
467 | enum Value { | ||
468 | Number(i32), | ||
469 | Text(String)$0, | ||
470 | } | ||
471 | "#####, | ||
472 | r#####" | ||
473 | enum Value { | ||
474 | Number(i32), | ||
475 | Text(String), | ||
476 | } | ||
477 | |||
478 | impl Value { | ||
479 | fn as_text(&self) -> Option<&String> { | ||
480 | if let Self::Text(v) = self { | ||
481 | Some(v) | ||
482 | } else { | ||
483 | None | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | "#####, | ||
488 | ) | ||
489 | } | ||
490 | |||
491 | #[test] | ||
492 | fn doctest_generate_enum_is_method() { | ||
493 | check_doc_test( | ||
494 | "generate_enum_is_method", | ||
466 | r#####" | 495 | r#####" |
467 | enum Version { | 496 | enum Version { |
468 | Undefined, | 497 | Undefined, |
@@ -488,6 +517,35 @@ impl Version { | |||
488 | } | 517 | } |
489 | 518 | ||
490 | #[test] | 519 | #[test] |
520 | fn doctest_generate_enum_try_into_method() { | ||
521 | check_doc_test( | ||
522 | "generate_enum_try_into_method", | ||
523 | r#####" | ||
524 | enum Value { | ||
525 | Number(i32), | ||
526 | Text(String)$0, | ||
527 | } | ||
528 | "#####, | ||
529 | r#####" | ||
530 | enum Value { | ||
531 | Number(i32), | ||
532 | Text(String), | ||
533 | } | ||
534 | |||
535 | impl Value { | ||
536 | fn try_into_text(self) -> Result<String, Self> { | ||
537 | if let Self::Text(v) = self { | ||
538 | Ok(v) | ||
539 | } else { | ||
540 | Err(self) | ||
541 | } | ||
542 | } | ||
543 | } | ||
544 | "#####, | ||
545 | ) | ||
546 | } | ||
547 | |||
548 | #[test] | ||
491 | fn doctest_generate_from_impl_for_enum() { | 549 | fn doctest_generate_from_impl_for_enum() { |
492 | check_doc_test( | 550 | check_doc_test( |
493 | "generate_from_impl_for_enum", | 551 | "generate_from_impl_for_enum", |
@@ -1099,6 +1157,29 @@ impl Debug for S { | |||
1099 | } | 1157 | } |
1100 | 1158 | ||
1101 | #[test] | 1159 | #[test] |
1160 | fn doctest_replace_for_loop_with_for_each() { | ||
1161 | check_doc_test( | ||
1162 | "replace_for_loop_with_for_each", | ||
1163 | r#####" | ||
1164 | fn main() { | ||
1165 | let x = vec![1, 2, 3]; | ||
1166 | for$0 v in x { | ||
1167 | let y = v * 2; | ||
1168 | } | ||
1169 | } | ||
1170 | "#####, | ||
1171 | r#####" | ||
1172 | fn main() { | ||
1173 | let x = vec![1, 2, 3]; | ||
1174 | x.into_iter().for_each(|v| { | ||
1175 | let y = v * 2; | ||
1176 | }); | ||
1177 | } | ||
1178 | "#####, | ||
1179 | ) | ||
1180 | } | ||
1181 | |||
1182 | #[test] | ||
1102 | fn doctest_replace_if_let_with_match() { | 1183 | fn doctest_replace_if_let_with_match() { |
1103 | check_doc_test( | 1184 | check_doc_test( |
1104 | "replace_if_let_with_match", | 1185 | "replace_if_let_with_match", |