aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-10 12:51:35 +0100
committerAleksey Kladov <[email protected]>2019-10-10 12:51:35 +0100
commit51402832774d876cdae8ac7042717e61d466b527 (patch)
treeaf7a30f05592bddec30c203cc24d804138b2f038
parentce0d4a3b1deaca318a1ed2ff83cca652ef8e8c82 (diff)
simplify some tests
-rw-r--r--crates/ra_hir/src/nameres/tests/mod_resolution.rs114
1 files changed, 24 insertions, 90 deletions
diff --git a/crates/ra_hir/src/nameres/tests/mod_resolution.rs b/crates/ra_hir/src/nameres/tests/mod_resolution.rs
index 755f5723b..f569aacdc 100644
--- a/crates/ra_hir/src/nameres/tests/mod_resolution.rs
+++ b/crates/ra_hir/src/nameres/tests/mod_resolution.rs
@@ -80,18 +80,15 @@ fn module_resolution_works_for_non_standard_filenames() {
80 80
81#[test] 81#[test]
82fn module_resolution_works_for_raw_modules() { 82fn module_resolution_works_for_raw_modules() {
83 let map = def_map_with_crate_graph( 83 let map = def_map(
84 " 84 "
85 //- /library.rs 85 //- /lib.rs
86 mod r#async; 86 mod r#async;
87 use self::r#async::Bar; 87 use self::r#async::Bar;
88 88
89 //- /async.rs 89 //- /async.rs
90 pub struct Bar; 90 pub struct Bar;
91 ", 91 ",
92 crate_graph! {
93 "library": ("/library.rs", []),
94 },
95 ); 92 );
96 93
97 assert_snapshot!(map, @r###" 94 assert_snapshot!(map, @r###"
@@ -106,9 +103,9 @@ fn module_resolution_works_for_raw_modules() {
106 103
107#[test] 104#[test]
108fn module_resolution_decl_path() { 105fn module_resolution_decl_path() {
109 let map = def_map_with_crate_graph( 106 let map = def_map(
110 r###" 107 r###"
111 //- /library.rs 108 //- /lib.rs
112 #[path = "bar/baz/foo.rs"] 109 #[path = "bar/baz/foo.rs"]
113 mod foo; 110 mod foo;
114 use self::foo::Bar; 111 use self::foo::Bar;
@@ -116,9 +113,6 @@ fn module_resolution_decl_path() {
116 //- /bar/baz/foo.rs 113 //- /bar/baz/foo.rs
117 pub struct Bar; 114 pub struct Bar;
118 "###, 115 "###,
119 crate_graph! {
120 "library": ("/library.rs", []),
121 },
122 ); 116 );
123 117
124 assert_snapshot!(map, @r###" 118 assert_snapshot!(map, @r###"
@@ -133,7 +127,7 @@ fn module_resolution_decl_path() {
133 127
134#[test] 128#[test]
135fn module_resolution_module_with_path_in_mod_rs() { 129fn module_resolution_module_with_path_in_mod_rs() {
136 let map = def_map_with_crate_graph( 130 let map = def_map(
137 r###" 131 r###"
138 //- /main.rs 132 //- /main.rs
139 mod foo; 133 mod foo;
@@ -147,9 +141,6 @@ fn module_resolution_module_with_path_in_mod_rs() {
147 //- /foo/baz.rs 141 //- /foo/baz.rs
148 pub struct Baz; 142 pub struct Baz;
149 "###, 143 "###,
150 crate_graph! {
151 "main": ("/main.rs", []),
152 },
153 ); 144 );
154 145
155 assert_snapshot!(map, @r###" 146 assert_snapshot!(map, @r###"
@@ -167,7 +158,7 @@ fn module_resolution_module_with_path_in_mod_rs() {
167 158
168#[test] 159#[test]
169fn module_resolution_module_with_path_non_crate_root() { 160fn module_resolution_module_with_path_non_crate_root() {
170 let map = def_map_with_crate_graph( 161 let map = def_map(
171 r###" 162 r###"
172 //- /main.rs 163 //- /main.rs
173 mod foo; 164 mod foo;
@@ -181,9 +172,6 @@ fn module_resolution_module_with_path_non_crate_root() {
181 //- /baz.rs 172 //- /baz.rs
182 pub struct Baz; 173 pub struct Baz;
183 "###, 174 "###,
184 crate_graph! {
185 "main": ("/main.rs", []),
186 },
187 ); 175 );
188 176
189 assert_snapshot!(map, @r###" 177 assert_snapshot!(map, @r###"
@@ -201,7 +189,7 @@ fn module_resolution_module_with_path_non_crate_root() {
201 189
202#[test] 190#[test]
203fn module_resolution_module_decl_path_super() { 191fn module_resolution_module_decl_path_super() {
204 let map = def_map_with_crate_graph( 192 let map = def_map(
205 r###" 193 r###"
206 //- /main.rs 194 //- /main.rs
207 #[path = "bar/baz/module.rs"] 195 #[path = "bar/baz/module.rs"]
@@ -211,9 +199,6 @@ fn module_resolution_module_decl_path_super() {
211 //- /bar/baz/module.rs 199 //- /bar/baz/module.rs
212 use super::Baz; 200 use super::Baz;
213 "###, 201 "###,
214 crate_graph! {
215 "main": ("/main.rs", []),
216 },
217 ); 202 );
218 203
219 assert_snapshot!(map, @r###" 204 assert_snapshot!(map, @r###"
@@ -228,7 +213,7 @@ fn module_resolution_module_decl_path_super() {
228 213
229#[test] 214#[test]
230fn module_resolution_explicit_path_mod_rs() { 215fn module_resolution_explicit_path_mod_rs() {
231 let map = def_map_with_crate_graph( 216 let map = def_map(
232 r###" 217 r###"
233 //- /main.rs 218 //- /main.rs
234 #[path = "module/mod.rs"] 219 #[path = "module/mod.rs"]
@@ -237,9 +222,6 @@ fn module_resolution_explicit_path_mod_rs() {
237 //- /module/mod.rs 222 //- /module/mod.rs
238 pub struct Baz; 223 pub struct Baz;
239 "###, 224 "###,
240 crate_graph! {
241 "main": ("/main.rs", []),
242 },
243 ); 225 );
244 226
245 assert_snapshot!(map, @r###" 227 assert_snapshot!(map, @r###"
@@ -253,7 +235,7 @@ fn module_resolution_explicit_path_mod_rs() {
253 235
254#[test] 236#[test]
255fn module_resolution_relative_path() { 237fn module_resolution_relative_path() {
256 let map = def_map_with_crate_graph( 238 let map = def_map(
257 r###" 239 r###"
258 //- /main.rs 240 //- /main.rs
259 mod foo; 241 mod foo;
@@ -265,9 +247,6 @@ fn module_resolution_relative_path() {
265 //- /sub.rs 247 //- /sub.rs
266 pub struct Baz; 248 pub struct Baz;
267 "###, 249 "###,
268 crate_graph! {
269 "main": ("/main.rs", []),
270 },
271 ); 250 );
272 251
273 assert_snapshot!(map, @r###" 252 assert_snapshot!(map, @r###"
@@ -284,7 +263,7 @@ fn module_resolution_relative_path() {
284 263
285#[test] 264#[test]
286fn module_resolution_relative_path_2() { 265fn module_resolution_relative_path_2() {
287 let map = def_map_with_crate_graph( 266 let map = def_map(
288 r###" 267 r###"
289 //- /main.rs 268 //- /main.rs
290 mod foo; 269 mod foo;
@@ -296,9 +275,6 @@ fn module_resolution_relative_path_2() {
296 //- /sub.rs 275 //- /sub.rs
297 pub struct Baz; 276 pub struct Baz;
298 "###, 277 "###,
299 crate_graph! {
300 "main": ("/main.rs", []),
301 },
302 ); 278 );
303 279
304 assert_snapshot!(map, @r###" 280 assert_snapshot!(map, @r###"
@@ -315,7 +291,7 @@ fn module_resolution_relative_path_2() {
315 291
316#[test] 292#[test]
317fn module_resolution_explicit_path_mod_rs_2() { 293fn module_resolution_explicit_path_mod_rs_2() {
318 let map = def_map_with_crate_graph( 294 let map = def_map(
319 r###" 295 r###"
320 //- /main.rs 296 //- /main.rs
321 #[path = "module/bar/mod.rs"] 297 #[path = "module/bar/mod.rs"]
@@ -324,9 +300,6 @@ fn module_resolution_explicit_path_mod_rs_2() {
324 //- /module/bar/mod.rs 300 //- /module/bar/mod.rs
325 pub struct Baz; 301 pub struct Baz;
326 "###, 302 "###,
327 crate_graph! {
328 "main": ("/main.rs", []),
329 },
330 ); 303 );
331 304
332 assert_snapshot!(map, @r###" 305 assert_snapshot!(map, @r###"
@@ -340,7 +313,7 @@ fn module_resolution_explicit_path_mod_rs_2() {
340 313
341#[test] 314#[test]
342fn module_resolution_explicit_path_mod_rs_with_win_separator() { 315fn module_resolution_explicit_path_mod_rs_with_win_separator() {
343 let map = def_map_with_crate_graph( 316 let map = def_map(
344 r###" 317 r###"
345 //- /main.rs 318 //- /main.rs
346 #[path = "module\bar\mod.rs"] 319 #[path = "module\bar\mod.rs"]
@@ -349,9 +322,6 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
349 //- /module/bar/mod.rs 322 //- /module/bar/mod.rs
350 pub struct Baz; 323 pub struct Baz;
351 "###, 324 "###,
352 crate_graph! {
353 "main": ("/main.rs", []),
354 },
355 ); 325 );
356 326
357 assert_snapshot!(map, @r###" 327 assert_snapshot!(map, @r###"
@@ -365,7 +335,7 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
365 335
366#[test] 336#[test]
367fn module_resolution_decl_inside_inline_module_with_path_attribute() { 337fn module_resolution_decl_inside_inline_module_with_path_attribute() {
368 let map = def_map_with_crate_graph( 338 let map = def_map(
369 r###" 339 r###"
370 //- /main.rs 340 //- /main.rs
371 #[path = "models"] 341 #[path = "models"]
@@ -376,9 +346,6 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
376 //- /models/bar.rs 346 //- /models/bar.rs
377 pub struct Baz; 347 pub struct Baz;
378 "###, 348 "###,
379 crate_graph! {
380 "main": ("/main.rs", []),
381 },
382 ); 349 );
383 350
384 assert_snapshot!(map, @r###" 351 assert_snapshot!(map, @r###"
@@ -395,7 +362,7 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
395 362
396#[test] 363#[test]
397fn module_resolution_decl_inside_inline_module() { 364fn module_resolution_decl_inside_inline_module() {
398 let map = def_map_with_crate_graph( 365 let map = def_map(
399 r###" 366 r###"
400 //- /main.rs 367 //- /main.rs
401 mod foo { 368 mod foo {
@@ -405,9 +372,6 @@ fn module_resolution_decl_inside_inline_module() {
405 //- /foo/bar.rs 372 //- /foo/bar.rs
406 pub struct Baz; 373 pub struct Baz;
407 "###, 374 "###,
408 crate_graph! {
409 "main": ("/main.rs", []),
410 },
411 ); 375 );
412 376
413 assert_snapshot!(map, @r###" 377 assert_snapshot!(map, @r###"
@@ -424,7 +388,7 @@ fn module_resolution_decl_inside_inline_module() {
424 388
425#[test] 389#[test]
426fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { 390fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
427 let map = def_map_with_crate_graph( 391 let map = def_map(
428 r###" 392 r###"
429 //- /main.rs 393 //- /main.rs
430 #[path = "models/db"] 394 #[path = "models/db"]
@@ -435,9 +399,6 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
435 //- /models/db/bar.rs 399 //- /models/db/bar.rs
436 pub struct Baz; 400 pub struct Baz;
437 "###, 401 "###,
438 crate_graph! {
439 "main": ("/main.rs", []),
440 },
441 ); 402 );
442 403
443 assert_snapshot!(map, @r###" 404 assert_snapshot!(map, @r###"
@@ -454,7 +415,7 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
454 415
455#[test] 416#[test]
456fn module_resolution_decl_inside_inline_module_3() { 417fn module_resolution_decl_inside_inline_module_3() {
457 let map = def_map_with_crate_graph( 418 let map = def_map(
458 r###" 419 r###"
459 //- /main.rs 420 //- /main.rs
460 #[path = "models/db"] 421 #[path = "models/db"]
@@ -466,9 +427,6 @@ fn module_resolution_decl_inside_inline_module_3() {
466 //- /models/db/users.rs 427 //- /models/db/users.rs
467 pub struct Baz; 428 pub struct Baz;
468 "###, 429 "###,
469 crate_graph! {
470 "main": ("/main.rs", []),
471 },
472 ); 430 );
473 431
474 assert_snapshot!(map, @r###" 432 assert_snapshot!(map, @r###"
@@ -485,7 +443,7 @@ fn module_resolution_decl_inside_inline_module_3() {
485 443
486#[test] 444#[test]
487fn module_resolution_decl_inside_inline_module_empty_path() { 445fn module_resolution_decl_inside_inline_module_empty_path() {
488 let map = def_map_with_crate_graph( 446 let map = def_map(
489 r###" 447 r###"
490 //- /main.rs 448 //- /main.rs
491 #[path = ""] 449 #[path = ""]
@@ -497,9 +455,6 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
497 //- /users.rs 455 //- /users.rs
498 pub struct Baz; 456 pub struct Baz;
499 "###, 457 "###,
500 crate_graph! {
501 "main": ("/main.rs", []),
502 },
503 ); 458 );
504 459
505 assert_snapshot!(map, @r###" 460 assert_snapshot!(map, @r###"
@@ -516,7 +471,7 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
516 471
517#[test] 472#[test]
518fn module_resolution_decl_empty_path() { 473fn module_resolution_decl_empty_path() {
519 let map = def_map_with_crate_graph( 474 let map = def_map(
520 r###" 475 r###"
521 //- /main.rs 476 //- /main.rs
522 #[path = ""] // Should try to read `/` (a directory) 477 #[path = ""] // Should try to read `/` (a directory)
@@ -525,9 +480,6 @@ fn module_resolution_decl_empty_path() {
525 //- /foo.rs 480 //- /foo.rs
526 pub struct Baz; 481 pub struct Baz;
527 "###, 482 "###,
528 crate_graph! {
529 "main": ("/main.rs", []),
530 },
531 ); 483 );
532 484
533 assert_snapshot!(map, @r###" 485 assert_snapshot!(map, @r###"
@@ -537,7 +489,7 @@ fn module_resolution_decl_empty_path() {
537 489
538#[test] 490#[test]
539fn module_resolution_decl_inside_inline_module_relative_path() { 491fn module_resolution_decl_inside_inline_module_relative_path() {
540 let map = def_map_with_crate_graph( 492 let map = def_map(
541 r###" 493 r###"
542 //- /main.rs 494 //- /main.rs
543 #[path = "./models"] 495 #[path = "./models"]
@@ -548,9 +500,6 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
548 //- /models/bar.rs 500 //- /models/bar.rs
549 pub struct Baz; 501 pub struct Baz;
550 "###, 502 "###,
551 crate_graph! {
552 "main": ("/main.rs", []),
553 },
554 ); 503 );
555 504
556 assert_snapshot!(map, @r###" 505 assert_snapshot!(map, @r###"
@@ -567,7 +516,7 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
567 516
568#[test] 517#[test]
569fn module_resolution_decl_inside_inline_module_in_crate_root() { 518fn module_resolution_decl_inside_inline_module_in_crate_root() {
570 let map = def_map_with_crate_graph( 519 let map = def_map(
571 r###" 520 r###"
572 //- /main.rs 521 //- /main.rs
573 mod foo { 522 mod foo {
@@ -579,9 +528,6 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
579 //- /foo/baz.rs 528 //- /foo/baz.rs
580 pub struct Baz; 529 pub struct Baz;
581 "###, 530 "###,
582 crate_graph! {
583 "main": ("/main.rs", []),
584 },
585 ); 531 );
586 532
587 assert_snapshot!(map, @r###" 533 assert_snapshot!(map, @r###"
@@ -599,7 +545,7 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
599 545
600#[test] 546#[test]
601fn module_resolution_decl_inside_inline_module_in_mod_rs() { 547fn module_resolution_decl_inside_inline_module_in_mod_rs() {
602 let map = def_map_with_crate_graph( 548 let map = def_map(
603 r###" 549 r###"
604 //- /main.rs 550 //- /main.rs
605 mod foo; 551 mod foo;
@@ -614,9 +560,6 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
614 //- /foo/bar/qwe.rs 560 //- /foo/bar/qwe.rs
615 pub struct Baz; 561 pub struct Baz;
616 "###, 562 "###,
617 crate_graph! {
618 "main": ("/main.rs", []),
619 },
620 ); 563 );
621 564
622 assert_snapshot!(map, @r###" 565 assert_snapshot!(map, @r###"
@@ -637,7 +580,7 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
637 580
638#[test] 581#[test]
639fn module_resolution_decl_inside_inline_module_in_non_crate_root() { 582fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
640 let map = def_map_with_crate_graph( 583 let map = def_map(
641 r###" 584 r###"
642 //- /main.rs 585 //- /main.rs
643 mod foo; 586 mod foo;
@@ -652,9 +595,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
652 //- /foo/bar/qwe.rs 595 //- /foo/bar/qwe.rs
653 pub struct Baz; 596 pub struct Baz;
654 "###, 597 "###,
655 crate_graph! {
656 "main": ("/main.rs", []),
657 },
658 ); 598 );
659 599
660 assert_snapshot!(map, @r###" 600 assert_snapshot!(map, @r###"
@@ -675,7 +615,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
675 615
676#[test] 616#[test]
677fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { 617fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
678 let map = def_map_with_crate_graph( 618 let map = def_map(
679 r###" 619 r###"
680 //- /main.rs 620 //- /main.rs
681 mod foo; 621 mod foo;
@@ -690,9 +630,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
690 //- /bar/baz.rs 630 //- /bar/baz.rs
691 pub struct Baz; 631 pub struct Baz;
692 "###, 632 "###,
693 crate_graph! {
694 "main": ("/main.rs", []),
695 },
696 ); 633 );
697 634
698 assert_snapshot!(map, @r###" 635 assert_snapshot!(map, @r###"
@@ -732,7 +669,7 @@ fn unresolved_module_diagnostics() {
732 669
733#[test] 670#[test]
734fn module_resolution_decl_inside_module_in_non_crate_root_2() { 671fn module_resolution_decl_inside_module_in_non_crate_root_2() {
735 let map = def_map_with_crate_graph( 672 let map = def_map(
736 r###" 673 r###"
737 //- /main.rs 674 //- /main.rs
738 #[path="module/m2.rs"] 675 #[path="module/m2.rs"]
@@ -744,9 +681,6 @@ fn module_resolution_decl_inside_module_in_non_crate_root_2() {
744 //- /module/submod.rs 681 //- /module/submod.rs
745 pub struct Baz; 682 pub struct Baz;
746 "###, 683 "###,
747 crate_graph! {
748 "main": ("/main.rs", []),
749 },
750 ); 684 );
751 685
752 assert_snapshot!(map, @r###" 686 assert_snapshot!(map, @r###"