@@ -1212,25 +1212,21 @@ func TestDoubleParamReturnCompletion(t *testing.T) {
1212
1212
Run (t , src , func (t * testing.T , env * Env ) {
1213
1213
env .OpenFile ("a.go" )
1214
1214
1215
- compl := env .RegexpSearch ("a.go" , `DoubleWrap\[()\]\(\)` )
1216
- result := env .Completion (compl )
1217
-
1218
- wantLabel := []string {"InterfaceA" , "TypeA" , "InterfaceB" , "TypeB" , "TypeC" }
1219
-
1220
- for i , item := range result .Items [:len (wantLabel )] {
1221
- if diff := cmp .Diff (wantLabel [i ], item .Label ); diff != "" {
1222
- t .Errorf ("Completion: unexpected label mismatch (-want +got):\n %s" , diff )
1223
- }
1215
+ tests := map [string ][]string {
1216
+ `DoubleWrap\[()\]\(\)` : {"InterfaceA" , "TypeA" , "InterfaceB" , "TypeB" , "TypeC" },
1217
+ `DoubleWrap\[InterfaceA, (_)\]\(\)` : {"InterfaceB" , "TypeB" , "TypeX" , "InterfaceA" , "TypeA" },
1224
1218
}
1225
1219
1226
- compl = env .RegexpSearch ("a.go" , `DoubleWrap\[InterfaceA, (_)\]\(\)` )
1227
- result = env .Completion (compl )
1228
-
1229
- wantLabel = []string {"InterfaceB" , "TypeB" , "TypeX" , "InterfaceA" , "TypeA" }
1230
-
1231
- for i , item := range result .Items [:len (wantLabel )] {
1232
- if diff := cmp .Diff (wantLabel [i ], item .Label ); diff != "" {
1233
- t .Errorf ("Completion: unexpected label mismatch (-want +got):\n %s" , diff )
1220
+ for re , wantLabels := range tests {
1221
+ compl := env .RegexpSearch ("a.go" , re )
1222
+ result := env .Completion (compl )
1223
+ if len (result .Items ) < len (wantLabels ) {
1224
+ t .Fatalf ("Completion(%q) returned mismatching labels: got %v, want at least labels %v" , re , result .Items , wantLabels )
1225
+ }
1226
+ for i , item := range result .Items [:len (wantLabels )] {
1227
+ if diff := cmp .Diff (wantLabels [i ], item .Label ); diff != "" {
1228
+ t .Errorf ("Completion(%q): unexpected label mismatch (-want +got):\n %s" , re , diff )
1229
+ }
1234
1230
}
1235
1231
}
1236
1232
})
0 commit comments