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
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
11 func TestStdlibReferences(t *testing.T) {
12         const files = `
13 -- go.mod --
14 module mod.com
15
16 -- main.go --
17 package main
18
19 import "fmt"
20
21 func main() {
22         fmt.Print()
23 }
24 `
25
26         run(t, files, func(t *testing.T, env *Env) {
27                 env.OpenFile("main.go")
28                 file, pos := env.GoToDefinition("main.go", env.RegexpSearch("main.go", `fmt.(Print)`))
29                 refs, err := env.Editor.References(env.Ctx, file, pos)
30                 if err != nil {
31                         t.Fatal(err)
32                 }
33                 if len(refs) != 2 {
34                         t.Fatalf("got %v reference(s), want 2", len(refs))
35                 }
36                 // The first reference is guaranteed to be the definition.
37                 if got, want := refs[1].URI, env.Sandbox.Workdir.URI("main.go"); got != want {
38                         t.Errorf("found reference in %v, wanted %v", got, want)
39                 }
40         })
41 }