mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: adjust Value.String to give correct answer for methods
Fixes #7859. LGTM=r R=adonovan, r CC=golang-codereviews https://golang.org/cl/136710043
This commit is contained in:
parent
2debfeb936
commit
dd8f29e3fe
2 changed files with 17 additions and 1 deletions
|
|
@ -3923,3 +3923,19 @@ func useStack(n int) {
|
|||
var b [1024]byte // makes frame about 1KB
|
||||
useStack(n - 1 + int(b[99]))
|
||||
}
|
||||
|
||||
type Impl struct{}
|
||||
|
||||
func (Impl) f() {}
|
||||
|
||||
func TestValueString(t *testing.T) {
|
||||
rv := ValueOf(Impl{})
|
||||
if rv.String() != "<reflect_test.Impl Value>" {
|
||||
t.Errorf("ValueOf(Impl{}).String() = %q, want %q", rv.String(), "<reflect_test.Impl Value>")
|
||||
}
|
||||
|
||||
method := rv.Method(0)
|
||||
if method.String() != "<func() Value>" {
|
||||
t.Errorf("ValueOf(Impl{}).Method(0).String() = %q, want %q", method.String(), "<func() Value>")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue