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 / references_test.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools/gopls@v0.5.2/internal/regtest/references_test.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools/gopls@v0.5.2/internal/regtest/references_test.go
new file mode 100644 (file)
index 0000000..a864092
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package regtest
+
+import (
+       "testing"
+)
+
+func TestStdlibReferences(t *testing.T) {
+       const files = `
+-- go.mod --
+module mod.com
+
+-- main.go --
+package main
+
+import "fmt"
+
+func main() {
+       fmt.Print()
+}
+`
+
+       run(t, files, func(t *testing.T, env *Env) {
+               env.OpenFile("main.go")
+               file, pos := env.GoToDefinition("main.go", env.RegexpSearch("main.go", `fmt.(Print)`))
+               refs, err := env.Editor.References(env.Ctx, file, pos)
+               if err != nil {
+                       t.Fatal(err)
+               }
+               if len(refs) != 2 {
+                       t.Fatalf("got %v reference(s), want 2", len(refs))
+               }
+               // The first reference is guaranteed to be the definition.
+               if got, want := refs[1].URI, env.Sandbox.Workdir.URI("main.go"); got != want {
+                       t.Errorf("found reference in %v, wanted %v", got, want)
+               }
+       })
+}