aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/tests
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-17 14:32:34 +0100
committerLukas Wirth <[email protected]>2021-06-17 14:32:34 +0100
commita9a77671f2405e0cb65160c17268beec5114e259 (patch)
tree24b2c740f849b17ccab5d1bfa2575c9fea840897 /crates/ide_completion/src/tests
parent9df848c58079a710869dcde2692466cc4b0ac78e (diff)
Move item specific completion tests
Diffstat (limited to 'crates/ide_completion/src/tests')
-rw-r--r--crates/ide_completion/src/tests/items.rs108
1 files changed, 108 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..dd4ba3864
--- /dev/null
+++ b/crates/ide_completion/src/tests/items.rs
@@ -0,0 +1,108 @@
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_].
5use expect_test::{expect, Expect};
6
7use crate::tests::completion_list;
8
9fn check(ra_fixture: &str, expect: Expect) {
10 let base = r#"#[rustc_builtin_macro]
11pub macro Clone {}
12enum Enum { Variant }
13struct Struct {}
14#[macro_export]
15macro_rules! foo {}
16mod bar {}
17const CONST: () = ();
18trait Trait {}
19"#;
20 let actual = completion_list(&format!("{}{}", base, ra_fixture));
21 expect.assert_eq(&actual)
22}
23
24#[test]
25fn target_type_or_trait_in_impl_block() {
26 // FIXME: should not complete `Self`
27 check(
28 r#"
29impl My$0
30"#,
31 expect![[r##"
32 sp Self
33 tt Trait
34 en Enum
35 st Struct
36 md bar
37 ma foo!(…) #[macro_export] macro_rules! foo
38 ma foo!(…) #[macro_export] macro_rules! foo
39 bt u32
40 bt bool
41 bt u8
42 bt isize
43 bt u16
44 bt u64
45 bt u128
46 bt f32
47 bt i128
48 bt i16
49 bt str
50 bt i64
51 bt char
52 bt f64
53 bt i32
54 bt i8
55 bt usize
56 "##]],
57 )
58}
59
60#[test]
61fn after_trait_name_in_trait_def() {
62 // FIXME: should only complete `where`
63 check(
64 r"trait A $0",
65 expect![[r##"
66 kw where
67 sn tmod (Test module)
68 sn tfn (Test function)
69 sn macro_rules
70 md bar
71 ma foo!(…) #[macro_export] macro_rules! foo
72 ma foo!(…) #[macro_export] macro_rules! foo
73 "##]],
74 );
75}
76
77#[test]
78fn after_trait_or_target_name_in_impl() {
79 // FIXME: should only complete `for` and `where`
80 check(
81 r"impl A $0",
82 expect![[r##"
83 kw where
84 sn tmod (Test module)
85 sn tfn (Test function)
86 sn macro_rules
87 md bar
88 ma foo!(…) #[macro_export] macro_rules! foo
89 ma foo!(…) #[macro_export] macro_rules! foo
90 "##]],
91 );
92}
93
94#[test]
95fn before_record_field() {
96 check(
97 r#"
98struct Foo {
99 $0
100 pub f: i32,
101}
102"#,
103 expect![[r#"
104 kw pub(crate)
105 kw pub
106 "#]],
107 )
108}