diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-17 14:44:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-17 14:44:38 +0100 |
commit | 3ae0c5911ab50ee209179ee4329b0551abe6fc48 (patch) | |
tree | 8c8fb1436a64a6bfd56558f41b734a966aa5725e /crates/ide_completion/src/tests/items.rs | |
parent | c82a9141abe6b6cbf5b55710dc8a315a3839081b (diff) | |
parent | 2a48b532208de413e4e5d39e81c33a4644ecaa22 (diff) |
Merge #9312
9312: internal: Move out item specific completion tests r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/tests/items.rs')
-rw-r--r-- | crates/ide_completion/src/tests/items.rs | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/crates/ide_completion/src/tests/items.rs b/crates/ide_completion/src/tests/items.rs new file mode 100644 index 000000000..8dfb8221b --- /dev/null +++ b/crates/ide_completion/src/tests/items.rs | |||
@@ -0,0 +1,127 @@ | |||
1 | //! Completions tests for item specifics overall. | ||
2 | //! | ||
3 | //! Except for use items which are tested in [super::use_tree] and mod declarations with are tested | ||
4 | //! in [crate::completions::mod_]. | ||
5 | use expect_test::{expect, Expect}; | ||
6 | |||
7 | use crate::tests::completion_list; | ||
8 | |||
9 | fn check(ra_fixture: &str, expect: Expect) { | ||
10 | let base = r#"#[rustc_builtin_macro] | ||
11 | pub macro Clone {} | ||
12 | enum Enum { Variant } | ||
13 | struct Struct {} | ||
14 | #[macro_export] | ||
15 | macro_rules! foo {} | ||
16 | mod bar {} | ||
17 | const CONST: () = (); | ||
18 | trait Trait {} | ||
19 | "#; | ||
20 | let actual = completion_list(&format!("{}{}", base, ra_fixture)); | ||
21 | expect.assert_eq(&actual) | ||
22 | } | ||
23 | |||
24 | #[test] | ||
25 | fn target_type_or_trait_in_impl_block() { | ||
26 | check( | ||
27 | r#" | ||
28 | impl Tra$0 | ||
29 | "#, | ||
30 | expect![[r##" | ||
31 | tt Trait | ||
32 | en Enum | ||
33 | st Struct | ||
34 | md bar | ||
35 | ma foo!(…) #[macro_export] macro_rules! foo | ||
36 | ma foo!(…) #[macro_export] macro_rules! foo | ||
37 | bt u32 | ||
38 | bt bool | ||
39 | bt u8 | ||
40 | bt isize | ||
41 | bt u16 | ||
42 | bt u64 | ||
43 | bt u128 | ||
44 | bt f32 | ||
45 | bt i128 | ||
46 | bt i16 | ||
47 | bt str | ||
48 | bt i64 | ||
49 | bt char | ||
50 | bt f64 | ||
51 | bt i32 | ||
52 | bt i8 | ||
53 | bt usize | ||
54 | "##]], | ||
55 | ) | ||
56 | } | ||
57 | |||
58 | #[test] | ||
59 | fn target_type_in_trait_impl_block() { | ||
60 | check( | ||
61 | r#" | ||
62 | impl Trait for Str$0 | ||
63 | "#, | ||
64 | expect![[r##" | ||
65 | tt Trait | ||
66 | en Enum | ||
67 | st Struct | ||
68 | md bar | ||
69 | ma foo!(…) #[macro_export] macro_rules! foo | ||
70 | ma foo!(…) #[macro_export] macro_rules! foo | ||
71 | bt u32 | ||
72 | bt bool | ||
73 | bt u8 | ||
74 | bt isize | ||
75 | bt u16 | ||
76 | bt u64 | ||
77 | bt u128 | ||
78 | bt f32 | ||
79 | bt i128 | ||
80 | bt i16 | ||
81 | bt str | ||
82 | bt i64 | ||
83 | bt char | ||
84 | bt f64 | ||
85 | bt i32 | ||
86 | bt i8 | ||
87 | bt usize | ||
88 | "##]], | ||
89 | ) | ||
90 | } | ||
91 | |||
92 | #[test] | ||
93 | fn after_trait_name_in_trait_def() { | ||
94 | check( | ||
95 | r"trait A $0", | ||
96 | expect![[r#" | ||
97 | kw where | ||
98 | "#]], | ||
99 | ); | ||
100 | } | ||
101 | |||
102 | #[test] | ||
103 | fn after_trait_or_target_name_in_impl() { | ||
104 | check( | ||
105 | r"impl Trait $0", | ||
106 | expect![[r#" | ||
107 | kw where | ||
108 | kw for | ||
109 | "#]], | ||
110 | ); | ||
111 | } | ||
112 | |||
113 | #[test] | ||
114 | fn before_record_field() { | ||
115 | check( | ||
116 | r#" | ||
117 | struct Foo { | ||
118 | $0 | ||
119 | pub f: i32, | ||
120 | } | ||
121 | "#, | ||
122 | expect![[r#" | ||
123 | kw pub(crate) | ||
124 | kw pub | ||
125 | "#]], | ||
126 | ) | ||
127 | } | ||