diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-03 21:34:50 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-03 21:34:50 +0000 |
commit | 4fd742d6bc23e2f61d0980e15234f09d7e715b76 (patch) | |
tree | c37d38f9313f54ea71580f6bd005f554388a57ab /crates/ra_hir_def/src/nameres/tests/globs.rs | |
parent | f9f1effd011b906903891c09f1cb6b2a42f73e95 (diff) | |
parent | 8922a44395482896fec0c0a47a7fac4612112d45 (diff) |
Merge #2163
2163: Move CrateDefMap to hir_def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres/tests/globs.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs new file mode 100644 index 000000000..5b03fe365 --- /dev/null +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -0,0 +1,114 @@ | |||
1 | use super::*; | ||
2 | |||
3 | #[test] | ||
4 | fn glob_1() { | ||
5 | let map = def_map( | ||
6 | " | ||
7 | //- /lib.rs | ||
8 | mod foo; | ||
9 | use foo::*; | ||
10 | |||
11 | //- /foo/mod.rs | ||
12 | pub mod bar; | ||
13 | pub use self::bar::Baz; | ||
14 | pub struct Foo; | ||
15 | |||
16 | //- /foo/bar.rs | ||
17 | pub struct Baz; | ||
18 | ", | ||
19 | ); | ||
20 | assert_snapshot!(map, @r###" | ||
21 | ⋮crate | ||
22 | ⋮Baz: t v | ||
23 | ⋮Foo: t v | ||
24 | ⋮bar: t | ||
25 | ⋮foo: t | ||
26 | ⋮ | ||
27 | ⋮crate::foo | ||
28 | ⋮Baz: t v | ||
29 | ⋮Foo: t v | ||
30 | ⋮bar: t | ||
31 | ⋮ | ||
32 | ⋮crate::foo::bar | ||
33 | ⋮Baz: t v | ||
34 | "### | ||
35 | ); | ||
36 | } | ||
37 | |||
38 | #[test] | ||
39 | fn glob_2() { | ||
40 | let map = def_map( | ||
41 | " | ||
42 | //- /lib.rs | ||
43 | mod foo; | ||
44 | use foo::*; | ||
45 | |||
46 | //- /foo/mod.rs | ||
47 | pub mod bar; | ||
48 | pub use self::bar::*; | ||
49 | pub struct Foo; | ||
50 | |||
51 | //- /foo/bar.rs | ||
52 | pub struct Baz; | ||
53 | pub use super::*; | ||
54 | ", | ||
55 | ); | ||
56 | assert_snapshot!(map, @r###" | ||
57 | ⋮crate | ||
58 | ⋮Baz: t v | ||
59 | ⋮Foo: t v | ||
60 | ⋮bar: t | ||
61 | ⋮foo: t | ||
62 | ⋮ | ||
63 | ⋮crate::foo | ||
64 | ⋮Baz: t v | ||
65 | ⋮Foo: t v | ||
66 | ⋮bar: t | ||
67 | ⋮ | ||
68 | ⋮crate::foo::bar | ||
69 | ⋮Baz: t v | ||
70 | ⋮Foo: t v | ||
71 | ⋮bar: t | ||
72 | "### | ||
73 | ); | ||
74 | } | ||
75 | |||
76 | #[test] | ||
77 | fn glob_across_crates() { | ||
78 | covers!(glob_across_crates); | ||
79 | let map = def_map( | ||
80 | " | ||
81 | //- /main.rs crate:main deps:test_crate | ||
82 | use test_crate::*; | ||
83 | |||
84 | //- /lib.rs crate:test_crate | ||
85 | pub struct Baz; | ||
86 | ", | ||
87 | ); | ||
88 | assert_snapshot!(map, @r###" | ||
89 | ⋮crate | ||
90 | ⋮Baz: t v | ||
91 | "### | ||
92 | ); | ||
93 | } | ||
94 | |||
95 | #[test] | ||
96 | fn glob_enum() { | ||
97 | covers!(glob_enum); | ||
98 | let map = def_map( | ||
99 | " | ||
100 | //- /lib.rs | ||
101 | enum Foo { | ||
102 | Bar, Baz | ||
103 | } | ||
104 | use self::Foo::*; | ||
105 | ", | ||
106 | ); | ||
107 | assert_snapshot!(map, @r###" | ||
108 | ⋮crate | ||
109 | ⋮Bar: t v | ||
110 | ⋮Baz: t v | ||
111 | ⋮Foo: t | ||
112 | "### | ||
113 | ); | ||
114 | } | ||