aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/tests/tests.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-31 14:15:34 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-31 14:15:34 +0000
commit2a65020442142b68b32c0a97672faeeba5ff399e (patch)
tree32791da6860ea906017a8d30157baedc08bee484 /crates/ra_analysis/tests/tests.rs
parent700b334a28b73133a25416319475eafe3ec11f90 (diff)
parent05daa86634b41aa3f311a1ac0b02bf7fed7ed569 (diff)
Merge #165
165: Make modules with tests runnable r=farodin91 a=farodin91 Fixes #154 I having problems to traverse the path to module. The main problem is that module_tree only supports `FileId` and not `Module` in files. Any idea? I need to clean up the code a bit later. Co-authored-by: Jan Jansen <[email protected]>
Diffstat (limited to 'crates/ra_analysis/tests/tests.rs')
-rw-r--r--crates/ra_analysis/tests/tests.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index a314fbc40..b61ead752 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -132,6 +132,56 @@ fn test_resolve_parent_module_for_inline() {
132} 132}
133 133
134#[test] 134#[test]
135fn test_path_one_layer() {
136 let (analysis, pos) = analysis_and_position(
137 "
138 //- /lib.rs
139 mod foo;
140 //- /foo/mod.rs
141 mod bla;
142 //- /foo/bla.rs
143 <|> //empty
144 ",
145 );
146 let symbols = analysis.module_path(pos).unwrap().unwrap();
147 assert_eq!("foo::bla", &symbols);
148}
149
150#[test]
151fn test_path_two_layer() {
152 let (analysis, pos) = analysis_and_position(
153 "
154 //- /lib.rs
155 mod foo;
156 //- /foo/mod.rs
157 mod bla;
158 //- /foo/bla/mod.rs
159 mod more;
160 //- /foo/bla/more.rs
161 <|> //empty
162 ",
163 );
164 let symbols = analysis.module_path(pos).unwrap().unwrap();
165 assert_eq!("foo::bla::more", &symbols);
166}
167
168#[test]
169fn test_path_in_file_mod() {
170 let (analysis, pos) = analysis_and_position(
171 "
172 //- /lib.rs
173 mod foo;
174 //- /foo.rs
175 mod bar {
176 <|> //empty
177 }
178 ",
179 );
180 let symbols = analysis.module_path(pos).unwrap().unwrap();
181 assert_eq!("foo::bar", &symbols);
182}
183
184#[test]
135fn test_resolve_crate_root() { 185fn test_resolve_crate_root() {
136 let mock = MockAnalysis::with_files( 186 let mock = MockAnalysis::with_files(
137 " 187 "