diff options
author | Edwin Cheng <[email protected]> | 2019-12-03 11:33:48 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-12-06 15:48:45 +0000 |
commit | 76ff5b7c15b2c4e85895a49e5859e546d1d6227e (patch) | |
tree | c7787cb5e4f1eae6c2946d880c9cdc6337535317 /crates | |
parent | a25e8cff6755c1a0c46ee3690dcd75b641c0b3e4 (diff) |
Add tests
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests.rs | 32 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 29 |
2 files changed, 61 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 87fcd617c..61cdd768e 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs | |||
@@ -558,3 +558,35 @@ fn cfg_test() { | |||
558 | ⋮Foo: t v | 558 | ⋮Foo: t v |
559 | "###); | 559 | "###); |
560 | } | 560 | } |
561 | |||
562 | #[test] | ||
563 | fn infer_multiple_namespace() { | ||
564 | let map = def_map( | ||
565 | r#" | ||
566 | //- /main.rs | ||
567 | mod a { | ||
568 | pub type T = (); | ||
569 | pub use crate::b::*; | ||
570 | } | ||
571 | |||
572 | use crate::a::T; | ||
573 | |||
574 | mod b { | ||
575 | pub const T: () = (); | ||
576 | } | ||
577 | "#, | ||
578 | ); | ||
579 | |||
580 | assert_snapshot!(map, @r###" | ||
581 | ⋮crate | ||
582 | ⋮T: t v | ||
583 | ⋮a: t | ||
584 | ⋮b: t | ||
585 | ⋮ | ||
586 | ⋮crate::b | ||
587 | ⋮T: v | ||
588 | ⋮ | ||
589 | ⋮crate::a | ||
590 | ⋮T: t v | ||
591 | "###); | ||
592 | } | ||
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 9c29a054e..812f171db 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -211,6 +211,35 @@ pub fn baz() -> usize { 31usize } | |||
211 | } | 211 | } |
212 | 212 | ||
213 | #[test] | 213 | #[test] |
214 | fn infer_type_value_non_legacy_macro_use_as() { | ||
215 | assert_snapshot!( | ||
216 | infer(r#" | ||
217 | mod m { | ||
218 | macro_rules! _foo { | ||
219 | ($x:ident) => { type $x = u64; } | ||
220 | } | ||
221 | pub(crate) use _foo as foo; | ||
222 | } | ||
223 | |||
224 | m::foo!(foo); | ||
225 | use foo as bar; | ||
226 | fn f() -> bar { 0 } | ||
227 | fn main() { | ||
228 | let _a = f(); | ||
229 | } | ||
230 | "#), | ||
231 | @r###" | ||
232 | [159; 164) '{ 0 }': u64 | ||
233 | [161; 162) '0': u64 | ||
234 | [175; 199) '{ ...f(); }': () | ||
235 | [187; 189) '_a': u64 | ||
236 | [193; 194) 'f': fn f() -> u64 | ||
237 | [193; 196) 'f()': u64 | ||
238 | "### | ||
239 | ); | ||
240 | } | ||
241 | |||
242 | #[test] | ||
214 | fn infer_builtin_macros_line() { | 243 | fn infer_builtin_macros_line() { |
215 | assert_snapshot!( | 244 | assert_snapshot!( |
216 | infer(r#" | 245 | infer(r#" |