2019-10-19 15:26:56 -06:00
|
|
|
// Copyright 2019 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 cmdtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-11-12 18:16:00 -07:00
|
|
|
"sort"
|
|
|
|
"testing"
|
|
|
|
|
2019-10-19 15:26:56 -06:00
|
|
|
"golang.org/x/tools/internal/span"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *runner) References(t *testing.T, spn span.Span, itemList []span.Span) {
|
2019-11-12 18:16:00 -07:00
|
|
|
var itemStrings []string
|
2019-10-19 15:26:56 -06:00
|
|
|
for _, i := range itemList {
|
2019-11-12 18:16:00 -07:00
|
|
|
itemStrings = append(itemStrings, fmt.Sprint(i))
|
|
|
|
}
|
|
|
|
sort.Strings(itemStrings)
|
|
|
|
var expect string
|
|
|
|
for _, i := range itemStrings {
|
|
|
|
expect += i + "\n"
|
2019-10-19 15:26:56 -06:00
|
|
|
}
|
2019-11-21 17:58:38 -07:00
|
|
|
expect = r.Normalize(expect)
|
2019-10-19 15:26:56 -06:00
|
|
|
|
|
|
|
uri := spn.URI()
|
|
|
|
filename := uri.Filename()
|
|
|
|
target := filename + fmt.Sprintf(":%v:%v", spn.Start().Line(), spn.Start().Column())
|
2019-11-21 17:58:38 -07:00
|
|
|
got, _ := r.NormalizeGoplsCmd(t, "references", target)
|
2019-10-19 15:26:56 -06:00
|
|
|
if expect != got {
|
|
|
|
t.Errorf("references failed for %s expected:\n%s\ngot:\n%s", target, expect, got)
|
|
|
|
}
|
|
|
|
}
|