mirror of https://github.com/golang/go.git
reflect: add test for variadic reflect.Type.Method
For #41737 Change-Id: Id065880dd7da54dec1b45662c202aeb7f8397c60 Reviewed-on: https://go-review.googlesource.com/c/go/+/258819 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
507a88c39b
commit
41df0e2218
|
|
@ -2405,8 +2405,14 @@ func TestVariadicMethodValue(t *testing.T) {
|
||||||
points := []Point{{20, 21}, {22, 23}, {24, 25}}
|
points := []Point{{20, 21}, {22, 23}, {24, 25}}
|
||||||
want := int64(p.TotalDist(points[0], points[1], points[2]))
|
want := int64(p.TotalDist(points[0], points[1], points[2]))
|
||||||
|
|
||||||
|
// Variadic method of type.
|
||||||
|
tfunc := TypeOf((func(Point, ...Point) int)(nil))
|
||||||
|
if tt := TypeOf(p).Method(4).Type; tt != tfunc {
|
||||||
|
t.Errorf("Variadic Method Type from TypeOf is %s; want %s", tt, tfunc)
|
||||||
|
}
|
||||||
|
|
||||||
// Curried method of value.
|
// Curried method of value.
|
||||||
tfunc := TypeOf((func(...Point) int)(nil))
|
tfunc = TypeOf((func(...Point) int)(nil))
|
||||||
v := ValueOf(p).Method(4)
|
v := ValueOf(p).Method(4)
|
||||||
if tt := v.Type(); tt != tfunc {
|
if tt := v.Type(); tt != tfunc {
|
||||||
t.Errorf("Variadic Method Type is %s; want %s", tt, tfunc)
|
t.Errorf("Variadic Method Type is %s; want %s", tt, tfunc)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue