1
0
mirror of https://github.com/golang/go synced 2024-11-17 07:54:41 -07:00

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:
Ian Lance Taylor 2020-10-01 14:55:11 -07:00
parent 507a88c39b
commit 41df0e2218

View File

@ -2405,8 +2405,14 @@ func TestVariadicMethodValue(t *testing.T) {
points := []Point{{20, 21}, {22, 23}, {24, 25}}
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.
tfunc := TypeOf((func(...Point) int)(nil))
tfunc = TypeOf((func(...Point) int)(nil))
v := ValueOf(p).Method(4)
if tt := v.Type(); tt != tfunc {
t.Errorf("Variadic Method Type is %s; want %s", tt, tfunc)