2019-10-29 02:55:42 -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"
|
|
|
|
"testing"
|
|
|
|
|
2020-02-04 20:44:33 -07:00
|
|
|
"golang.org/x/tools/internal/lsp/protocol"
|
2019-10-29 02:55:42 -06:00
|
|
|
"golang.org/x/tools/internal/span"
|
|
|
|
)
|
|
|
|
|
2020-02-04 20:44:33 -07:00
|
|
|
func (r *runner) SignatureHelp(t *testing.T, spn span.Span, want *protocol.SignatureHelp) {
|
2019-10-29 02:55:42 -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, "signature", target)
|
2020-02-04 20:44:33 -07:00
|
|
|
if want == nil {
|
|
|
|
if got != "" {
|
|
|
|
t.Fatalf("want nil, but got %s", got)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
goldenTag := want.Signatures[0].Label + "-signature"
|
2019-10-29 02:55:42 -06:00
|
|
|
expect := string(r.data.Golden(goldenTag, filename, func() ([]byte, error) {
|
|
|
|
return []byte(got), nil
|
|
|
|
}))
|
|
|
|
if expect != got {
|
2019-11-22 12:49:12 -07:00
|
|
|
t.Errorf("signature failed for %s expected:\n%q\ngot:\n%q'", filename, expect, got)
|
2019-10-29 02:55:42 -06:00
|
|
|
}
|
|
|
|
}
|