Skip to content

Commit

Permalink
reflect: add test for variadic reflect.Type.Method
Browse files Browse the repository at this point in the history
For #41737

Change-Id: Id065880dd7da54dec1b45662c202aeb7f8397c60
Reviewed-on: https://go-review.googlesource.com/c/go/+/258819
Trust: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
  • Loading branch information
ianlancetaylor committed Oct 1, 2020
1 parent 507a88c commit 41df0e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/reflect/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 41df0e2

Please sign in to comment.