Skip to content

Commit

Permalink
gopls/internal/lsp: enable min/max builtin completion test
Browse files Browse the repository at this point in the history
For golang/go#59488

Change-Id: I93680138c90750454b4d94af6dc84fe942c9dd34
Reviewed-on: https://go-review.googlesource.com/c/tools/+/498516
Run-TryBot: Cuong Manh Le <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Cuong Manh Le <[email protected]>
gopls-CI: kokoro <[email protected]>
  • Loading branch information
cuonglm authored and gopherbot committed Jun 5, 2023
1 parent 86c93e8 commit 726c727
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
17 changes: 2 additions & 15 deletions gopls/internal/lsp/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (r *runner) Completion(t *testing.T, src span.Span, test tests.Completion,
opts.LiteralCompletions = strings.Contains(string(src.URI()), "literal")
opts.ExperimentalPostfixCompletions = strings.Contains(string(src.URI()), "postfix")
})
got = filterSkipCompletionItems(tests.FilterBuiltins(src, got))
want := filterSkipCompletionItems(expected(t, test, items))
got = tests.FilterBuiltins(src, got)
want := expected(t, test, items)
if diff := tests.DiffCompletionItems(want, got); diff != "" {
t.Errorf("mismatching completion items (-want +got):\n%s", diff)
}
Expand Down Expand Up @@ -175,16 +175,3 @@ func (r *runner) callCompletion(t *testing.T, src span.Span, options func(*sourc
}
return list.Items
}

func filterSkipCompletionItems(items []protocol.CompletionItem) []protocol.CompletionItem {
n := 0
for _, item := range items {
// TODO(cuonglm): remove once https://go-review.googlesource.com/c/go/+/498495 land.
if item.Label == "max" || item.Label == "min" {
continue
}
items[n] = item
n++
}
return items[:n]
}
4 changes: 2 additions & 2 deletions gopls/internal/lsp/testdata/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ package builtins
/* int8 */ //@item(int8, "int8", "", "type")
/* iota */ //@item(iota, "iota", "", "const")
/* len(v Type) int */ //@item(len, "len", "func(v Type) int", "func")
/* max(x Type, y ...Type) Type */ //@item(max, "max", "func(x Type, y ...Type) Type", "func")
/* min(y Type, y ...Type) Type */ //@item(min, "min", "func(y Type, y ...Type) Type", "func")
/* max(x T, y ...T) T */ //@item(max, "max", "func(x T, y ...T) T", "func")
/* min(y T, y ...T) T */ //@item(min, "min", "func(x T, y ...T) T", "func")
/* make(t Type, size ...int) Type */ //@item(make, "make", "func(t Type, size ...int) Type", "func")
/* new(Type) *Type */ //@item(new, "new", "func(Type) *Type", "func")
/* nil */ //@item(_nil, "nil", "", "var")
Expand Down

0 comments on commit 726c727

Please sign in to comment.