diff options
author | Aleksey Kladov <[email protected]> | 2019-11-03 20:35:48 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-03 20:35:48 +0000 |
commit | 6fba51c5fc05264abcbf971dcf28142746588d74 (patch) | |
tree | edbdbf98b279802ee8dc03f35e941943e1e20e10 /crates/ra_hir_def/src/nameres/tests/globs.rs | |
parent | 0933d914a37c4ab57fda6fe95464d194dab6f80c (diff) |
move crate_def_map tests to hir_def
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..cf4a2a851 --- /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 | } | ||