diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 66f63ca24..25dad81eb 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -3,6 +3,7 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use insta::assert_snapshot; | 4 | use insta::assert_snapshot; |
5 | 5 | ||
6 | use ra_cfg::CfgOptions; | ||
6 | use ra_db::{salsa::Database, FilePosition, SourceDatabase}; | 7 | use ra_db::{salsa::Database, FilePosition, SourceDatabase}; |
7 | use ra_syntax::{ | 8 | use ra_syntax::{ |
8 | algo, | 9 | algo, |
@@ -24,6 +25,50 @@ mod never_type; | |||
24 | mod coercion; | 25 | mod coercion; |
25 | 26 | ||
26 | #[test] | 27 | #[test] |
28 | fn cfg_impl_block() { | ||
29 | let (mut db, pos) = MockDatabase::with_position( | ||
30 | r#" | ||
31 | //- /main.rs | ||
32 | use foo::S as T; | ||
33 | struct S; | ||
34 | |||
35 | #[cfg(test)] | ||
36 | impl S { | ||
37 | fn foo1(&self) -> i32 { 0 } | ||
38 | } | ||
39 | |||
40 | #[cfg(not(test))] | ||
41 | impl S { | ||
42 | fn foo2(&self) -> i32 { 0 } | ||
43 | } | ||
44 | |||
45 | fn test() { | ||
46 | let t = (S.foo1(), S.foo2(), T.foo3(), T.foo4()); | ||
47 | t<|>; | ||
48 | } | ||
49 | |||
50 | //- /foo.rs | ||
51 | struct S; | ||
52 | |||
53 | #[cfg(not(test))] | ||
54 | impl S { | ||
55 | fn foo3(&self) -> i32 { 0 } | ||
56 | } | ||
57 | |||
58 | #[cfg(test)] | ||
59 | impl S { | ||
60 | fn foo4(&self) -> i32 { 0 } | ||
61 | } | ||
62 | "#, | ||
63 | ); | ||
64 | db.set_crate_graph_from_fixture(crate_graph! { | ||
65 | "main": ("/main.rs", ["foo"], CfgOptions::default().atom("test".into())), | ||
66 | "foo": ("/foo.rs", []), | ||
67 | }); | ||
68 | assert_eq!("(i32, {unknown}, i32, {unknown})", type_at_pos(&db, pos)); | ||
69 | } | ||
70 | |||
71 | #[test] | ||
27 | fn infer_await() { | 72 | fn infer_await() { |
28 | let (mut db, pos) = MockDatabase::with_position( | 73 | let (mut db, pos) = MockDatabase::with_position( |
29 | r#" | 74 | r#" |