diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/basics.txt | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/binary_op.txt | 46 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/boolean_op.txt | 31 |
4 files changed, 56 insertions, 38 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e6c7e225b..2749d740c 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -157,7 +157,7 @@ impl S { | |||
157 | } | 157 | } |
158 | 158 | ||
159 | #[test] | 159 | #[test] |
160 | fn infer_boolean_op() { | 160 | fn infer_binary_op() { |
161 | check_inference( | 161 | check_inference( |
162 | r#" | 162 | r#" |
163 | fn f(x: bool) -> i32 { | 163 | fn f(x: bool) -> i32 { |
@@ -168,15 +168,18 @@ fn test() { | |||
168 | let x = a && b; | 168 | let x = a && b; |
169 | let y = true || false; | 169 | let y = true || false; |
170 | let z = x == y; | 170 | let z = x == y; |
171 | let h = CONST_1 <= CONST_2; | 171 | let minus_forty: isize = -40isize; |
172 | let h = minus_forty <= CONST_2; | ||
172 | let c = f(z || y) + 5; | 173 | let c = f(z || y) + 5; |
173 | let d = b; | 174 | let d = b; |
174 | let e = 3i32 && "hello world"; | 175 | let g = minus_forty ^= i; |
176 | let ten: usize = 10; | ||
177 | let ten_is_eleven = ten == some_num; | ||
175 | 178 | ||
176 | 10 < 3 | 179 | ten < 3 |
177 | } | 180 | } |
178 | "#, | 181 | "#, |
179 | "boolean_op.txt", | 182 | "binary_op.txt", |
180 | ); | 183 | ); |
181 | } | 184 | } |
182 | 185 | ||
diff --git a/crates/ra_hir/src/ty/tests/data/basics.txt b/crates/ra_hir/src/ty/tests/data/basics.txt index 8ea244ba8..ac7faae0a 100644 --- a/crates/ra_hir/src/ty/tests/data/basics.txt +++ b/crates/ra_hir/src/ty/tests/data/basics.txt | |||
@@ -1,12 +1,12 @@ | |||
1 | [9; 10) 'a': u32 | 1 | [9; 10) 'a': u32 |
2 | [17; 18) 'b': isize | 2 | [17; 18) 'b': isize |
3 | [27; 28) 'c': ! | 3 | [27; 28) 'c': ! |
4 | [33; 34) 'd': &[unknown] | 4 | [33; 34) 'd': &str |
5 | [42; 121) '{ ...f32; }': () | 5 | [42; 121) '{ ...f32; }': () |
6 | [48; 49) 'a': u32 | 6 | [48; 49) 'a': u32 |
7 | [55; 56) 'b': isize | 7 | [55; 56) 'b': isize |
8 | [62; 63) 'c': ! | 8 | [62; 63) 'c': ! |
9 | [69; 70) 'd': &[unknown] | 9 | [69; 70) 'd': &str |
10 | [76; 82) '1usize': [unknown] | 10 | [76; 82) '1usize': [unknown] |
11 | [88; 94) '1isize': [unknown] | 11 | [88; 94) '1isize': [unknown] |
12 | [100; 106) '"test"': [unknown] | 12 | [100; 106) '"test"': [unknown] |
diff --git a/crates/ra_hir/src/ty/tests/data/binary_op.txt b/crates/ra_hir/src/ty/tests/data/binary_op.txt new file mode 100644 index 000000000..0fb9dc097 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/binary_op.txt | |||
@@ -0,0 +1,46 @@ | |||
1 | [6; 7) 'x': bool | ||
2 | [22; 34) '{ 0i32 }': i32 | ||
3 | [28; 32) '0i32': i32 | ||
4 | [46; 342) '{ ... < 3 }': bool | ||
5 | [56; 57) 'x': bool | ||
6 | [60; 61) 'a': bool | ||
7 | [60; 66) 'a && b': bool | ||
8 | [65; 66) 'b': bool | ||
9 | [76; 77) 'y': bool | ||
10 | [80; 84) 'true': bool | ||
11 | [80; 93) 'true || false': bool | ||
12 | [88; 93) 'false': bool | ||
13 | [103; 104) 'z': bool | ||
14 | [107; 108) 'x': bool | ||
15 | [107; 113) 'x == y': bool | ||
16 | [112; 113) 'y': bool | ||
17 | [123; 134) 'minus_forty': isize | ||
18 | [144; 152) '-40isize': isize | ||
19 | [145; 152) '40isize': [unknown] | ||
20 | [162; 163) 'h': bool | ||
21 | [166; 177) 'minus_forty': isize | ||
22 | [166; 188) 'minus_...ONST_2': bool | ||
23 | [181; 188) 'CONST_2': isize | ||
24 | [198; 199) 'c': i32 | ||
25 | [202; 203) 'f': fn(bool,) -> i32 | ||
26 | [202; 211) 'f(z || y)': i32 | ||
27 | [202; 215) 'f(z || y) + 5': i32 | ||
28 | [204; 205) 'z': bool | ||
29 | [204; 210) 'z || y': bool | ||
30 | [209; 210) 'y': bool | ||
31 | [214; 215) '5': i32 | ||
32 | [225; 226) 'd': [unknown] | ||
33 | [229; 230) 'b': [unknown] | ||
34 | [240; 241) 'g': () | ||
35 | [244; 255) 'minus_forty': isize | ||
36 | [244; 260) 'minus_...y ^= i': () | ||
37 | [259; 260) 'i': isize | ||
38 | [270; 273) 'ten': usize | ||
39 | [283; 285) '10': usize | ||
40 | [295; 308) 'ten_is_eleven': bool | ||
41 | [311; 314) 'ten': usize | ||
42 | [311; 326) 'ten == some_num': bool | ||
43 | [318; 326) 'some_num': usize | ||
44 | [333; 336) 'ten': usize | ||
45 | [333; 340) 'ten < 3': bool | ||
46 | [339; 340) '3': usize | ||
diff --git a/crates/ra_hir/src/ty/tests/data/boolean_op.txt b/crates/ra_hir/src/ty/tests/data/boolean_op.txt deleted file mode 100644 index cce8d68fb..000000000 --- a/crates/ra_hir/src/ty/tests/data/boolean_op.txt +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | [6; 7) 'x': [unknown] | ||
2 | [22; 34) '{ 0i32 }': i32 | ||
3 | [28; 32) '0i32': i32 | ||
4 | [46; 237) '{ ... < 3 }': bool | ||
5 | [56; 57) 'x': bool | ||
6 | [60; 61) 'a': bool | ||
7 | [60; 66) 'a && b': bool | ||
8 | [65; 66) 'b': bool | ||
9 | [76; 77) 'y': bool | ||
10 | [80; 84) 'true': bool | ||
11 | [80; 93) 'true || false': bool | ||
12 | [88; 93) 'false': bool | ||
13 | [103; 104) 'z': bool | ||
14 | [107; 108) 'x': bool | ||
15 | [107; 113) 'x == y': bool | ||
16 | [112; 113) 'y': bool | ||
17 | [123; 124) 'h': bool | ||
18 | [127; 134) 'CONST_1': [unknown] | ||
19 | [127; 145) 'CONST_...ONST_2': bool | ||
20 | [138; 145) 'CONST_2': [unknown] | ||
21 | [155; 156) 'c': [unknown] | ||
22 | [159; 172) 'f(z || y) + 5': [unknown] | ||
23 | [182; 183) 'd': [unknown] | ||
24 | [186; 187) 'b': [unknown] | ||
25 | [197; 198) 'e': bool | ||
26 | [201; 205) '3i32': bool | ||
27 | [201; 222) '3i32 &...world"': bool | ||
28 | [209; 222) '"hello world"': bool | ||
29 | [229; 231) '10': [unknown] | ||
30 | [229; 235) '10 < 3': bool | ||
31 | [234; 235) '3': [unknown] | ||