| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package completion |
| 6 |
|
| 7 |
import ( |
| 8 |
"testing" |
| 9 |
|
| 10 |
. "golang.org/x/tools/gopls/internal/test/integration" |
| 11 |
) |
| 12 |
|
| 13 |
func TestPackageCompletionCrash_Issue68169(t *testing.T) { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
const files = ` |
| 19 |
-- go.mod -- |
| 20 |
module example.com |
| 21 |
|
| 22 |
go 1.18 |
| 23 |
-- playdos/play.go -- |
| 24 |
package // comment (to preserve spaces) |
| 25 |
` |
| 26 |
|
| 27 |
Run(t, files, func(t *testing.T, env *Env) { |
| 28 |
env.OpenFile("playdos/play.go") |
| 29 |
|
| 30 |
|
| 31 |
completions := env.Completion(env.RegexpSearch("playdos/play.go", "package ()")) |
| 32 |
if len(completions.Items) == 0 { |
| 33 |
t.Fatal("Completion() returned empty results") |
| 34 |
} |
| 35 |
|
| 36 |
if got, want := completions.Items[0].Label, "package playdos"; got != want { |
| 37 |
t.Errorf("Completion()[0].Label == %s, want %s", got, want) |
| 38 |
} |
| 39 |
}) |
| 40 |
} |
| 41 |
|
| 42 |
func TestFixInitStatementCrash_Issue72026(t *testing.T) { |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
const files = ` |
| 47 |
-- go.mod -- |
| 48 |
module example.com |
| 49 |
|
| 50 |
go 1.18 |
| 51 |
` |
| 52 |
|
| 53 |
Run(t, files, func(t *testing.T, env *Env) { |
| 54 |
env.CreateBuffer("p.go", "package p\nfunc _() {\n\tfor i := struct") |
| 55 |
env.AfterChange() |
| 56 |
}) |
| 57 |
} |