diff options
author | Hirokazu Hata <[email protected]> | 2019-01-03 03:01:52 +0000 |
---|---|---|
committer | Hirokazu Hata <[email protected]> | 2019-01-03 03:07:20 +0000 |
commit | f5992964edb0e6dba7970c344b46bfd75f57e9a0 (patch) | |
tree | 4e97d6c21771a2b470580277796f5c87150cdf61 /crates/ra_analysis/tests | |
parent | a4c30d750411f09a999b201631000a08e88907fd (diff) |
Add Analysis#teype_of test
Diffstat (limited to 'crates/ra_analysis/tests')
-rw-r--r-- | crates/ra_analysis/tests/tests.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs index 3045c2e78..ce6f6f3fa 100644 --- a/crates/ra_analysis/tests/tests.rs +++ b/crates/ra_analysis/tests/tests.rs | |||
@@ -2,7 +2,7 @@ use ra_syntax::TextRange; | |||
2 | use test_utils::{assert_eq_dbg, assert_eq_text}; | 2 | use test_utils::{assert_eq_dbg, assert_eq_text}; |
3 | 3 | ||
4 | use ra_analysis::{ | 4 | use ra_analysis::{ |
5 | mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis}, | 5 | mock_analysis::{analysis_and_position, analysis_and_range, single_file, single_file_with_position, MockAnalysis}, |
6 | AnalysisChange, CrateGraph, FileId, FnSignatureInfo, | 6 | AnalysisChange, CrateGraph, FileId, FnSignatureInfo, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -10,6 +10,22 @@ fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) { | |||
10 | let (analysis, position) = single_file_with_position(text); | 10 | let (analysis, position) = single_file_with_position(text); |
11 | analysis.resolve_callable(position).unwrap().unwrap() | 11 | analysis.resolve_callable(position).unwrap().unwrap() |
12 | } | 12 | } |
13 | #[test] | ||
14 | fn test_type_of() { | ||
15 | let (analysis, range) = analysis_and_range( | ||
16 | " | ||
17 | //- /lib.rs | ||
18 | pub fn foo() -> u32 { | ||
19 | 1 | ||
20 | }; | ||
21 | |||
22 | let <|>foo_test<|> = foo(); | ||
23 | ", | ||
24 | ); | ||
25 | |||
26 | let type_name = analysis.type_of(range).unwrap().unwrap(); | ||
27 | assert_eq_dbg("u32", &type_name); | ||
28 | } | ||
13 | 29 | ||
14 | #[test] | 30 | #[test] |
15 | fn approximate_resolve_works_in_items() { | 31 | fn approximate_resolve_works_in_items() { |