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.rs97
1 files changed, 79 insertions, 18 deletions
diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs
index 7f6dbbccf..3f77edd8d 100644
--- a/crates/ide_assists/src/tests/generated.rs
+++ b/crates/ide_assists/src/tests/generated.rs
@@ -193,37 +193,44 @@ pub(crate) fn frobnicate() {}
193} 193}
194 194
195#[test] 195#[test]
196fn doctest_convert_for_to_iter_for_each() { 196fn doctest_convert_integer_literal() {
197 check_doc_test( 197 check_doc_test(
198 "convert_for_to_iter_for_each", 198 "convert_integer_literal",
199 r#####" 199 r#####"
200fn main() { 200const _: i32 = 10$0;
201 let x = vec![1, 2, 3];
202 for $0v in x {
203 let y = v * 2;
204 }
205}
206"#####, 201"#####,
207 r#####" 202 r#####"
208fn main() { 203const _: i32 = 0b1010;
209 let x = vec![1, 2, 3];
210 x.into_iter().for_each(|v| {
211 let y = v * 2;
212 });
213}
214"#####, 204"#####,
215 ) 205 )
216} 206}
217 207
218#[test] 208#[test]
219fn doctest_convert_integer_literal() { 209fn doctest_convert_iter_for_each_to_for() {
220 check_doc_test( 210 check_doc_test(
221 "convert_integer_literal", 211 "convert_iter_for_each_to_for",
222 r#####" 212 r#####"
223const _: i32 = 10$0; 213//- /lib.rs crate:core
214pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } }
215pub struct SomeIter;
216impl self::iter::traits::iterator::Iterator for SomeIter {}
217//- /lib.rs crate:main deps:core
218use core::SomeIter;
219fn main() {
220 let iter = SomeIter;
221 iter.for_each$0(|(x, y)| {
222 println!("x: {}, y: {}", x, y);
223 });
224}
224"#####, 225"#####,
225 r#####" 226 r#####"
226const _: i32 = 0b1010; 227use core::SomeIter;
228fn main() {
229 let iter = SomeIter;
230 for (x, y) in iter {
231 println!("x: {}, y: {}", x, y);
232 }
233}
227"#####, 234"#####,
228 ) 235 )
229} 236}
@@ -463,6 +470,37 @@ impl Default for Version {
463} 470}
464 471
465#[test] 472#[test]
473fn doctest_generate_default_from_new() {
474 check_doc_test(
475 "generate_default_from_new",
476 r#####"
477struct Example { _inner: () }
478
479impl Example {
480 pub fn n$0ew() -> Self {
481 Self { _inner: () }
482 }
483}
484"#####,
485 r#####"
486struct Example { _inner: () }
487
488impl Example {
489 pub fn new() -> Self {
490 Self { _inner: () }
491 }
492}
493
494impl Default for Example {
495 fn default() -> Self {
496 Self::new()
497 }
498}
499"#####,
500 )
501}
502
503#[test]
466fn doctest_generate_derive() { 504fn doctest_generate_derive() {
467 check_doc_test( 505 check_doc_test(
468 "generate_derive", 506 "generate_derive",
@@ -1180,6 +1218,29 @@ impl Debug for S {
1180} 1218}
1181 1219
1182#[test] 1220#[test]
1221fn doctest_replace_for_loop_with_for_each() {
1222 check_doc_test(
1223 "replace_for_loop_with_for_each",
1224 r#####"
1225fn main() {
1226 let x = vec![1, 2, 3];
1227 for$0 v in x {
1228 let y = v * 2;
1229 }
1230}
1231"#####,
1232 r#####"
1233fn main() {
1234 let x = vec![1, 2, 3];
1235 x.into_iter().for_each(|v| {
1236 let y = v * 2;
1237 });
1238}
1239"#####,
1240 )
1241}
1242
1243#[test]
1183fn doctest_replace_if_let_with_match() { 1244fn doctest_replace_if_let_with_match() {
1184 check_doc_test( 1245 check_doc_test(
1185 "replace_if_let_with_match", 1246 "replace_if_let_with_match",