internal/lsp: use a marker test for struct field ranking test
Change-Id: I70faef2c789a3cc7b4dee8c7dd5dcac0e06d7568
Reviewed-on: https://go-review.googlesource.com/c/tools/+/270880
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/gopls/internal/regtest/completion_test.go b/gopls/internal/regtest/completion_test.go
index 5978f56..2651f59 100644
--- a/gopls/internal/regtest/completion_test.go
+++ b/gopls/internal/regtest/completion_test.go
@@ -193,54 +193,6 @@
})
}
-// Test the order of completion suggestions
-func TestStructLiteralCompletion(t *testing.T) {
- const files = `
--- go.mod --
-module mod.com
-
--- foo.go --
-package foo
-
-type Foo struct {
- c int
- b int
- a int
-}
-
-func f() {
- foo := Foo{
-
- }
-}
-`
-
- want := []string{"c", "b", "a"}
-
- run(t, files, func(t *testing.T, env *Env) {
- env.OpenFile("foo.go")
- completions := env.Completion("foo.go", fake.Pos{
- Line: 10,
- Column: 0,
- })
-
- diff := compareCompletionResultsOnlyHead(want, completions.Items)
- if diff != "" {
- t.Fatal(diff)
- return
- }
- })
-}
-
-func compareCompletionResultsOnlyHead(want []string, gotItems []protocol.CompletionItem) string {
- for i := range want {
- if want[i] != gotItems[i].Label {
- return fmt.Sprintf("completion results are not the same: got %v, want %v", gotItems[i].Label, want[i])
- }
- }
- return ""
-}
-
func compareCompletionResults(want []string, gotItems []protocol.CompletionItem) string {
if len(gotItems) != len(want) {
return fmt.Sprintf("got %v completion(s), want %v", len(gotItems), len(want))
diff --git a/internal/lsp/testdata/rank/struct/struct_rank.go b/internal/lsp/testdata/rank/struct/struct_rank.go
new file mode 100644
index 0000000..e0bdd38
--- /dev/null
+++ b/internal/lsp/testdata/rank/struct/struct_rank.go
@@ -0,0 +1,11 @@
+package struct_rank
+
+type foo struct {
+ c int //@item(c_rank, "c", "int", "field")
+ b int //@item(b_rank, "b", "int", "field")
+ a int //@item(a_rank, "a", "int", "field")
+}
+
+func f() {
+ foo := foo{} //@rank("}", c_rank, b_rank, a_rank)
+}
diff --git a/internal/lsp/testdata/summary.txt.golden b/internal/lsp/testdata/summary.txt.golden
index 3771c85..f10805c 100644
--- a/internal/lsp/testdata/summary.txt.golden
+++ b/internal/lsp/testdata/summary.txt.golden
@@ -6,7 +6,7 @@
UnimportedCompletionsCount = 5
DeepCompletionsCount = 5
FuzzyCompletionsCount = 8
-RankedCompletionsCount = 157
+RankedCompletionsCount = 158
CaseSensitiveCompletionsCount = 4
DiagnosticsCount = 43
FoldingRangesCount = 2