aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src/tests')
-rw-r--r--crates/ide_assists/src/tests/generated.rs108
1 files changed, 83 insertions, 25 deletions
diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs
index d42875822..4f007aa48 100644
--- a/crates/ide_assists/src/tests/generated.rs
+++ b/crates/ide_assists/src/tests/generated.rs
@@ -193,29 +193,6 @@ pub(crate) fn frobnicate() {}
193} 193}
194 194
195#[test] 195#[test]
196fn doctest_convert_for_to_iter_for_each() {
197 check_doc_test(
198 "convert_for_to_iter_for_each",
199 r#####"
200fn main() {
201 let x = vec![1, 2, 3];
202 for $0v in x {
203 let y = v * 2;
204 }
205}
206"#####,
207 r#####"
208fn main() {
209 let x = vec![1, 2, 3];
210 x.into_iter().for_each(|v| {
211 let y = v * 2;
212 });
213}
214"#####,
215 )
216}
217
218#[test]
219fn doctest_convert_integer_literal() { 196fn doctest_convert_integer_literal() {
220 check_doc_test( 197 check_doc_test(
221 "convert_integer_literal", 198 "convert_integer_literal",
@@ -483,9 +460,38 @@ struct Point {
483} 460}
484 461
485#[test] 462#[test]
486fn doctest_generate_enum_match_method() { 463fn doctest_generate_enum_as_method() {
464 check_doc_test(
465 "generate_enum_as_method",
466 r#####"
467enum Value {
468 Number(i32),
469 Text(String)$0,
470}
471"#####,
472 r#####"
473enum Value {
474 Number(i32),
475 Text(String),
476}
477
478impl 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]
492fn doctest_generate_enum_is_method() {
487 check_doc_test( 493 check_doc_test(
488 "generate_enum_match_method", 494 "generate_enum_is_method",
489 r#####" 495 r#####"
490enum Version { 496enum Version {
491 Undefined, 497 Undefined,
@@ -511,6 +517,35 @@ impl Version {
511} 517}
512 518
513#[test] 519#[test]
520fn doctest_generate_enum_try_into_method() {
521 check_doc_test(
522 "generate_enum_try_into_method",
523 r#####"
524enum Value {
525 Number(i32),
526 Text(String)$0,
527}
528"#####,
529 r#####"
530enum Value {
531 Number(i32),
532 Text(String),
533}
534
535impl 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]
514fn doctest_generate_from_impl_for_enum() { 549fn doctest_generate_from_impl_for_enum() {
515 check_doc_test( 550 check_doc_test(
516 "generate_from_impl_for_enum", 551 "generate_from_impl_for_enum",
@@ -1122,6 +1157,29 @@ impl Debug for S {
1122} 1157}
1123 1158
1124#[test] 1159#[test]
1160fn doctest_replace_for_loop_with_for_each() {
1161 check_doc_test(
1162 "replace_for_loop_with_for_each",
1163 r#####"
1164fn main() {
1165 let x = vec![1, 2, 3];
1166 for$0 v in x {
1167 let y = v * 2;
1168 }
1169}
1170"#####,
1171 r#####"
1172fn 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]
1125fn doctest_replace_if_let_with_match() { 1183fn doctest_replace_if_let_with_match() {
1126 check_doc_test( 1184 check_doc_test(
1127 "replace_if_let_with_match", 1185 "replace_if_let_with_match",