diff options
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r-- | crates/ra_analysis/src/hover.rs | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/hover.rs b/crates/ra_analysis/src/hover.rs index 8217df305..2cf79eebf 100644 --- a/crates/ra_analysis/src/hover.rs +++ b/crates/ra_analysis/src/hover.rs | |||
@@ -167,7 +167,7 @@ impl NavigationTarget { | |||
167 | #[cfg(test)] | 167 | #[cfg(test)] |
168 | mod tests { | 168 | mod tests { |
169 | use ra_syntax::TextRange; | 169 | use ra_syntax::TextRange; |
170 | use crate::mock_analysis::single_file_with_position; | 170 | use crate::mock_analysis::{single_file_with_position, single_file_with_range}; |
171 | 171 | ||
172 | #[test] | 172 | #[test] |
173 | fn hover_shows_type_of_an_expression() { | 173 | fn hover_shows_type_of_an_expression() { |
@@ -191,4 +191,52 @@ mod tests { | |||
191 | let hover = analysis.hover(position).unwrap().unwrap(); | 191 | let hover = analysis.hover(position).unwrap().unwrap(); |
192 | assert_eq!(hover.info, "i32"); | 192 | assert_eq!(hover.info, "i32"); |
193 | } | 193 | } |
194 | |||
195 | #[test] | ||
196 | fn test_type_of_for_function() { | ||
197 | let (analysis, range) = single_file_with_range( | ||
198 | " | ||
199 | pub fn foo() -> u32 { 1 }; | ||
200 | |||
201 | fn main() { | ||
202 | let foo_test = <|>foo()<|>; | ||
203 | } | ||
204 | ", | ||
205 | ); | ||
206 | |||
207 | let type_name = analysis.type_of(range).unwrap().unwrap(); | ||
208 | assert_eq!("u32", &type_name); | ||
209 | } | ||
210 | |||
211 | // FIXME: improve type_of to make this work | ||
212 | #[test] | ||
213 | fn test_type_of_for_expr_1() { | ||
214 | let (analysis, range) = single_file_with_range( | ||
215 | " | ||
216 | fn main() { | ||
217 | let foo = <|>1 + foo_test<|>; | ||
218 | } | ||
219 | ", | ||
220 | ); | ||
221 | |||
222 | let type_name = analysis.type_of(range).unwrap().unwrap(); | ||
223 | assert_eq!("[unknown]", &type_name); | ||
224 | } | ||
225 | |||
226 | // FIXME: improve type_of to make this work | ||
227 | #[test] | ||
228 | fn test_type_of_for_expr_2() { | ||
229 | let (analysis, range) = single_file_with_range( | ||
230 | " | ||
231 | fn main() { | ||
232 | let foo: usize = 1; | ||
233 | let bar = <|>1 + foo_test<|>; | ||
234 | } | ||
235 | ", | ||
236 | ); | ||
237 | |||
238 | let type_name = analysis.type_of(range).unwrap().unwrap(); | ||
239 | assert_eq!("[unknown]", &type_name); | ||
240 | } | ||
241 | |||
194 | } | 242 | } |