diff options
Diffstat (limited to 'crates/hir_ty/src/tests/display_source_code.rs')
-rw-r--r-- | crates/hir_ty/src/tests/display_source_code.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/display_source_code.rs b/crates/hir_ty/src/tests/display_source_code.rs new file mode 100644 index 000000000..b502135d8 --- /dev/null +++ b/crates/hir_ty/src/tests/display_source_code.rs | |||
@@ -0,0 +1,41 @@ | |||
1 | use super::check_types_source_code; | ||
2 | |||
3 | #[test] | ||
4 | fn qualify_path_to_submodule() { | ||
5 | check_types_source_code( | ||
6 | r#" | ||
7 | mod foo { | ||
8 | pub struct Foo; | ||
9 | } | ||
10 | |||
11 | fn bar() { | ||
12 | let foo: foo::Foo = foo::Foo; | ||
13 | foo | ||
14 | } //^ foo::Foo | ||
15 | |||
16 | "#, | ||
17 | ); | ||
18 | } | ||
19 | |||
20 | #[test] | ||
21 | fn omit_default_type_parameters() { | ||
22 | check_types_source_code( | ||
23 | r#" | ||
24 | struct Foo<T = u8> { t: T } | ||
25 | fn main() { | ||
26 | let foo = Foo { t: 5u8 }; | ||
27 | foo; | ||
28 | } //^ Foo | ||
29 | "#, | ||
30 | ); | ||
31 | |||
32 | check_types_source_code( | ||
33 | r#" | ||
34 | struct Foo<K, T = u8> { k: K, t: T } | ||
35 | fn main() { | ||
36 | let foo = Foo { k: 400, t: 5u8 }; | ||
37 | foo; | ||
38 | } //^ Foo<i32> | ||
39 | "#, | ||
40 | ); | ||
41 | } | ||