@@ -54,85 +54,81 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
54
54
55
55
#[ cfg( test) ]
56
56
mod tests {
57
- use crate :: completion:: { test_utils:: do_completion, CompletionItem , CompletionKind } ;
58
- use insta:: assert_debug_snapshot;
57
+ use expect:: { expect, Expect } ;
59
58
60
- fn do_magic_completion ( code : & str ) -> Vec < CompletionItem > {
61
- do_completion ( code, CompletionKind :: Magic )
59
+ use crate :: completion:: { test_utils:: do_completion, CompletionKind } ;
60
+
61
+ fn check ( ra_fixture : & str , expect : Expect ) {
62
+ let actual = do_completion ( ra_fixture, CompletionKind :: Magic ) ;
63
+ expect. assert_debug_eq ( & actual) ;
62
64
}
63
65
64
66
#[ test]
65
67
fn test_param_completion_last_param ( ) {
66
- assert_debug_snapshot ! (
67
- do_magic_completion(
68
- r"
69
- fn foo(file_id: FileId) {}
70
- fn bar(file_id: FileId) {}
71
- fn baz(file<|>) {}
72
- " ,
73
- ) ,
74
- @r###"
75
- [
76
- CompletionItem {
77
- label: "file_id: FileId",
78
- source_range: 61..65,
79
- delete: 61..65,
80
- insert: "file_id: FileId",
81
- lookup: "file_id",
82
- },
83
- ]
84
- "###
68
+ check (
69
+ r#"
70
+ fn foo(file_id: FileId) {}
71
+ fn bar(file_id: FileId) {}
72
+ fn baz(file<|>) {}
73
+ "# ,
74
+ expect ! [ [ r#"
75
+ [
76
+ CompletionItem {
77
+ label: "file_id: FileId",
78
+ source_range: 61..65,
79
+ delete: 61..65,
80
+ insert: "file_id: FileId",
81
+ lookup: "file_id",
82
+ },
83
+ ]
84
+ "# ] ] ,
85
85
) ;
86
86
}
87
87
88
88
#[ test]
89
89
fn test_param_completion_nth_param ( ) {
90
- assert_debug_snapshot ! (
91
- do_magic_completion(
92
- r"
93
- fn foo(file_id: FileId) {}
94
- fn bar(file_id: FileId) {}
95
- fn baz(file<|>, x: i32) {}
96
- " ,
97
- ) ,
98
- @r###"
99
- [
100
- CompletionItem {
101
- label: "file_id: FileId",
102
- source_range: 61..65,
103
- delete: 61..65,
104
- insert: "file_id: FileId",
105
- lookup: "file_id",
106
- },
107
- ]
108
- "###
90
+ check (
91
+ r#"
92
+ fn foo(file_id: FileId) {}
93
+ fn bar(file_id: FileId) {}
94
+ fn baz(file<|>, x: i32) {}
95
+ "# ,
96
+ expect ! [ [ r#"
97
+ [
98
+ CompletionItem {
99
+ label: "file_id: FileId",
100
+ source_range: 61..65,
101
+ delete: 61..65,
102
+ insert: "file_id: FileId",
103
+ lookup: "file_id",
104
+ },
105
+ ]
106
+ "# ] ] ,
109
107
) ;
110
108
}
111
109
112
110
#[ test]
113
111
fn test_param_completion_trait_param ( ) {
114
- assert_debug_snapshot ! (
115
- do_magic_completion(
116
- r"
117
- pub(crate) trait SourceRoot {
118
- pub fn contains(&self, file_id: FileId) -> bool;
119
- pub fn module_map(&self) -> &ModuleMap;
120
- pub fn lines(&self, file_id: FileId) -> &LineIndex;
121
- pub fn syntax(&self, file<|>)
122
- }
123
- " ,
124
- ) ,
125
- @r###"
126
- [
127
- CompletionItem {
128
- label: "file_id: FileId",
129
- source_range: 208..212,
130
- delete: 208..212,
131
- insert: "file_id: FileId",
132
- lookup: "file_id",
133
- },
134
- ]
135
- "###
112
+ check (
113
+ r#"
114
+ pub(crate) trait SourceRoot {
115
+ pub fn contains(&self, file_id: FileId) -> bool;
116
+ pub fn module_map(&self) -> &ModuleMap;
117
+ pub fn lines(&self, file_id: FileId) -> &LineIndex;
118
+ pub fn syntax(&self, file<|>)
119
+ }
120
+ "# ,
121
+ expect ! [ [ r#"
122
+ [
123
+ CompletionItem {
124
+ label: "file_id: FileId",
125
+ source_range: 208..212,
126
+ delete: 208..212,
127
+ insert: "file_id: FileId",
128
+ lookup: "file_id",
129
+ },
130
+ ]
131
+ "# ] ] ,
136
132
) ;
137
133
}
138
134
}
0 commit comments