Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.5.2 / internal / regtest / fix_test.go
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package regtest
6
7 import (
8         "testing"
9
10         "golang.org/x/tools/internal/lsp/protocol"
11         "golang.org/x/tools/internal/lsp/tests"
12 )
13
14 // A basic test for fillstruct, now that it uses a command.
15 func TestFillStruct(t *testing.T) {
16         const basic = `
17 -- go.mod --
18 module mod.com
19
20 go 1.14
21 -- main.go --
22 package main
23
24 import "go/types"
25
26 func Foo() {
27         _ = types.Info{}
28 }
29 `
30         runner.Run(t, basic, func(t *testing.T, env *Env) {
31                 env.OpenFile("main.go")
32                 if err := env.Editor.RefactorRewrite(env.Ctx, "main.go", &protocol.Range{
33                         Start: protocol.Position{
34                                 Line:      5,
35                                 Character: 16,
36                         },
37                         End: protocol.Position{
38                                 Line:      5,
39                                 Character: 16,
40                         },
41                 }); err != nil {
42                         t.Fatal(err)
43                 }
44                 want := `package main
45
46 import "go/types"
47
48 func Foo() {
49         _ = types.Info{
50                 Types:      map[ast.Expr]types.TypeAndValue{},
51                 Defs:       map[*ast.Ident]types.Object{},
52                 Uses:       map[*ast.Ident]types.Object{},
53                 Implicits:  map[ast.Node]types.Object{},
54                 Selections: map[*ast.SelectorExpr]*types.Selection{},
55                 Scopes:     map[ast.Node]*types.Scope{},
56                 InitOrder:  []*types.Initializer{},
57         }
58 }
59 `
60                 if got := env.Editor.BufferText("main.go"); got != want {
61                         t.Fatalf("TestFillStruct failed:\n%s", tests.Diff(want, got))
62                 }
63         })
64 }