Skip to content

Commit d5947d9

Browse files
committed
Clarify what the outline test module is for
1 parent 2d696b9 commit d5947d9

File tree

6 files changed

+115
-119
lines changed

6 files changed

+115
-119
lines changed

crates/ide_completion/src/completions/record.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,77 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
4444

4545
Some(())
4646
}
47+
48+
#[cfg(test)]
49+
mod tests {
50+
51+
use crate::tests::check_edit;
52+
53+
#[test]
54+
fn default_completion_edit() {
55+
check_edit(
56+
"..Default::default()",
57+
r#"
58+
//- minicore: default
59+
struct Struct { foo: u32, bar: usize }
60+
61+
impl Default for Struct {
62+
fn default() -> Self {}
63+
}
64+
65+
fn foo() {
66+
let other = Struct {
67+
foo: 5,
68+
.$0
69+
};
70+
}
71+
"#,
72+
r#"
73+
struct Struct { foo: u32, bar: usize }
74+
75+
impl Default for Struct {
76+
fn default() -> Self {}
77+
}
78+
79+
fn foo() {
80+
let other = Struct {
81+
foo: 5,
82+
..Default::default()
83+
};
84+
}
85+
"#,
86+
);
87+
check_edit(
88+
"..Default::default()",
89+
r#"
90+
//- minicore: default
91+
struct Struct { foo: u32, bar: usize }
92+
93+
impl Default for Struct {
94+
fn default() -> Self {}
95+
}
96+
97+
fn foo() {
98+
let other = Struct {
99+
foo: 5,
100+
$0
101+
};
102+
}
103+
"#,
104+
r#"
105+
struct Struct { foo: u32, bar: usize }
106+
107+
impl Default for Struct {
108+
fn default() -> Self {}
109+
}
110+
111+
fn foo() {
112+
let other = Struct {
113+
foo: 5,
114+
..Default::default()
115+
};
116+
}
117+
"#,
118+
);
119+
}
120+
}

crates/ide_completion/src/completions/snippet.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,4 @@ mod tests {
108108
"#]],
109109
);
110110
}
111-
112-
#[test]
113-
fn should_not_complete_snippets_in_path() {
114-
check(r#"fn foo(x: i32) { ::foo$0 }"#, expect![[""]]);
115-
check(r#"fn foo(x: i32) { ::$0 }"#, expect![[""]]);
116-
}
117111
}

crates/ide_completion/src/completions/trait_impl.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -299,29 +299,6 @@ mod tests {
299299
expect.assert_eq(&actual)
300300
}
301301

302-
#[test]
303-
fn name_ref_function_type_const() {
304-
check(
305-
r#"
306-
trait Test {
307-
type TestType;
308-
const TEST_CONST: u16;
309-
fn test();
310-
}
311-
struct T;
312-
313-
impl Test for T {
314-
t$0
315-
}
316-
"#,
317-
expect![["
318-
ta type TestType = \n\
319-
ct const TEST_CONST: u16 = \n\
320-
fn fn test()
321-
"]],
322-
);
323-
}
324-
325302
#[test]
326303
fn no_completion_inside_fn() {
327304
check(
@@ -572,27 +549,6 @@ impl Test for T {
572549
);
573550
}
574551

575-
#[test]
576-
fn hide_implemented_fn() {
577-
check(
578-
r#"
579-
trait Test {
580-
fn foo();
581-
fn foo_bar();
582-
}
583-
struct T;
584-
585-
impl Test for T {
586-
fn foo() {}
587-
fn f$0
588-
}
589-
"#,
590-
expect![[r#"
591-
fn fn foo_bar()
592-
"#]],
593-
);
594-
}
595-
596552
#[test]
597553
fn generic_fn() {
598554
check_edit(

crates/ide_completion/src/tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
//! Most tests live in this module or its submodules unless for very specific completions like
44
//! `attributes` or `lifetimes` where the completed concept is a distinct thing.
55
//! Notable examples for completions that are being tested in this module's submodule are paths.
6+
//! Another exception are `check_edit` tests which usually live in the completion modules themselves,
7+
//! as the main purpose of this test module here is to give the developer an overview of whats being
8+
//! completed where, not how.
69
710
mod attribute;
811
mod fn_param;

crates/ide_completion/src/tests/item_list.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,40 @@ fn in_trait_assoc_item_list() {
210210
"##]],
211211
);
212212
}
213+
214+
#[test]
215+
fn in_trait_impl_assoc_item_list() {
216+
check(
217+
r#"
218+
trait Test {
219+
type Type0;
220+
type Type1;
221+
const CONST0: ();
222+
const CONST1: ();
223+
fn function0();
224+
fn function1();
225+
}
226+
227+
impl Test for () {
228+
type Type0 = ();
229+
const CONST0: () = ();
230+
fn function0() {}
231+
$0
232+
}
233+
"#,
234+
expect![[r##"
235+
kw pub(crate)
236+
kw pub
237+
kw unsafe
238+
kw fn
239+
kw const
240+
kw type
241+
kw self
242+
kw super
243+
kw crate
244+
md module
245+
ma makro!(…) #[macro_export] macro_rules! makro
246+
ma makro!(…) #[macro_export] macro_rules! makro
247+
"##]],
248+
);
249+
}

crates/ide_completion/src/tests/record.rs

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use expect_test::{expect, Expect};
22

3-
use crate::tests::{check_edit, completion_list};
3+
use crate::tests::completion_list;
44

55
fn check(ra_fixture: &str, expect: Expect) {
66
let actual = completion_list(ra_fixture);
@@ -162,71 +162,3 @@ fn main() {
162162
"#]],
163163
);
164164
}
165-
166-
#[test]
167-
fn default_completion_edit() {
168-
check_edit(
169-
"..Default::default()",
170-
r#"
171-
//- minicore: default
172-
struct Struct { foo: u32, bar: usize }
173-
174-
impl Default for Struct {
175-
fn default() -> Self {}
176-
}
177-
178-
fn foo() {
179-
let other = Struct {
180-
foo: 5,
181-
.$0
182-
};
183-
}
184-
"#,
185-
r#"
186-
struct Struct { foo: u32, bar: usize }
187-
188-
impl Default for Struct {
189-
fn default() -> Self {}
190-
}
191-
192-
fn foo() {
193-
let other = Struct {
194-
foo: 5,
195-
..Default::default()
196-
};
197-
}
198-
"#,
199-
);
200-
check_edit(
201-
"..Default::default()",
202-
r#"
203-
//- minicore: default
204-
struct Struct { foo: u32, bar: usize }
205-
206-
impl Default for Struct {
207-
fn default() -> Self {}
208-
}
209-
210-
fn foo() {
211-
let other = Struct {
212-
foo: 5,
213-
$0
214-
};
215-
}
216-
"#,
217-
r#"
218-
struct Struct { foo: u32, bar: usize }
219-
220-
impl Default for Struct {
221-
fn default() -> Self {}
222-
}
223-
224-
fn foo() {
225-
let other = Struct {
226-
foo: 5,
227-
..Default::default()
228-
};
229-
}
230-
"#,
231-
);
232-
}

0 commit comments

Comments
 (0)