aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-03 10:06:32 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-03 10:06:32 +0000
commitd29e98dd975c6d72a62f3d3e178fef1e2ae8fc6a (patch)
tree47ca5c1b38a62cdec8548d6060b68a1cb3a8a5da /crates/ra_analysis
parente92f2ffe270c6a9fca312fb8a53cd0da0dd01fde (diff)
parent4363e7b9b2de715b0108b53d40eb33ed2fcc8532 (diff)
Merge #409
409: Add Analysis#teype_of test r=matklad a=h-michael Co-authored-by: Hirokazu Hata <[email protected]>
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/tests/type_of.rs79
1 files changed, 79 insertions, 0 deletions
diff --git a/crates/ra_analysis/tests/type_of.rs b/crates/ra_analysis/tests/type_of.rs
new file mode 100644
index 000000000..375f808bb
--- /dev/null
+++ b/crates/ra_analysis/tests/type_of.rs
@@ -0,0 +1,79 @@
1use ra_analysis::{
2 mock_analysis::{single_file_with_range},
3};
4
5#[test]
6fn test_type_of_for_function() {
7 let (analysis, range) = single_file_with_range(
8 "
9 pub fn foo() -> u32 { 1 };
10
11 fn main() {
12 let foo_test = <|>foo()<|>;
13 }
14 ",
15 );
16
17 let type_name = analysis.type_of(range).unwrap().unwrap();
18 assert_eq!("u32", &type_name);
19}
20
21// FIXME: improve type_of to make this work
22#[test]
23fn test_type_of_for_num() {
24 let (analysis, range) = single_file_with_range(
25 r#"
26 fn main() {
27 let foo_test = <|>"foo"<|>;
28 }
29 "#,
30 );
31
32 assert!(analysis.type_of(range).unwrap().is_none());
33}
34// FIXME: improve type_of to make this work
35#[test]
36fn test_type_of_for_binding() {
37 let (analysis, range) = single_file_with_range(
38 "
39 pub fn foo() -> u32 { 1 };
40
41 fn main() {
42 let <|>foo_test<|> = foo();
43 }
44 ",
45 );
46
47 assert!(analysis.type_of(range).unwrap().is_none());
48}
49
50// FIXME: improve type_of to make this work
51#[test]
52fn test_type_of_for_expr_1() {
53 let (analysis, range) = single_file_with_range(
54 "
55 fn main() {
56 let foo = <|>1 + foo_test<|>;
57 }
58 ",
59 );
60
61 let type_name = analysis.type_of(range).unwrap().unwrap();
62 assert_eq!("[unknown]", &type_name);
63}
64
65// FIXME: improve type_of to make this work
66#[test]
67fn test_type_of_for_expr_2() {
68 let (analysis, range) = single_file_with_range(
69 "
70 fn main() {
71 let foo: usize = 1;
72 let bar = <|>1 + foo_test<|>;
73 }
74 ",
75 );
76
77 let type_name = analysis.type_of(range).unwrap().unwrap();
78 assert_eq!("[unknown]", &type_name);
79}