diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 23 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/unary_op.txt | 28 |
2 files changed, 51 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 929fee04c..5d7bc25cc 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -159,6 +159,29 @@ fn test() { | |||
159 | } | 159 | } |
160 | 160 | ||
161 | #[test] | 161 | #[test] |
162 | fn infer_unary_op() { | ||
163 | check_inference( | ||
164 | r#" | ||
165 | enum SomeType {} | ||
166 | |||
167 | fn test(x: SomeType) { | ||
168 | let b = false; | ||
169 | let c = !b; | ||
170 | let a = 100; | ||
171 | let d: i128 = -a; | ||
172 | let e = -100; | ||
173 | let f = !!!true; | ||
174 | -3.14; | ||
175 | -x; | ||
176 | !x; | ||
177 | -"hello"; | ||
178 | } | ||
179 | "#, | ||
180 | "unary_op.txt", | ||
181 | ); | ||
182 | } | ||
183 | |||
184 | #[test] | ||
162 | fn infer_backwards() { | 185 | fn infer_backwards() { |
163 | check_inference( | 186 | check_inference( |
164 | r#" | 187 | r#" |
diff --git a/crates/ra_hir/src/ty/tests/data/unary_op.txt b/crates/ra_hir/src/ty/tests/data/unary_op.txt new file mode 100644 index 000000000..203022e82 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/unary_op.txt | |||
@@ -0,0 +1,28 @@ | |||
1 | [27; 28) 'x': SomeType | ||
2 | [40; 197) '{ ...lo"; }': () | ||
3 | [50; 51) 'b': bool | ||
4 | [54; 59) 'false': bool | ||
5 | [69; 70) 'c': bool | ||
6 | [73; 75) '!b': bool | ||
7 | [74; 75) 'b': bool | ||
8 | [85; 86) 'a': i128 | ||
9 | [89; 92) '100': i128 | ||
10 | [102; 103) 'd': i128 | ||
11 | [112; 114) '-a': i128 | ||
12 | [113; 114) 'a': i128 | ||
13 | [124; 125) 'e': i32 | ||
14 | [128; 132) '-100': i32 | ||
15 | [129; 132) '100': i32 | ||
16 | [142; 143) 'f': bool | ||
17 | [146; 153) '!!!true': bool | ||
18 | [147; 153) '!!true': bool | ||
19 | [148; 153) '!true': bool | ||
20 | [149; 153) 'true': bool | ||
21 | [159; 164) '-3.14': f64 | ||
22 | [160; 164) '3.14': f64 | ||
23 | [170; 172) '-x': [unknown] | ||
24 | [171; 172) 'x': SomeType | ||
25 | [178; 180) '!x': [unknown] | ||
26 | [179; 180) 'x': SomeType | ||
27 | [186; 194) '-"hello"': [unknown] | ||
28 | [187; 194) '"hello"': &str | ||