Skip to content

Commit 41df0e2

Browse files
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 <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent 507a88c commit 41df0e2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/reflect/all_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2405,8 +2405,14 @@ func TestVariadicMethodValue(t *testing.T) {
24052405
points := []Point{{20, 21}, {22, 23}, {24, 25}}
24062406
want := int64(p.TotalDist(points[0], points[1], points[2]))
24072407

2408+
// Variadic method of type.
2409+
tfunc := TypeOf((func(Point, ...Point) int)(nil))
2410+
if tt := TypeOf(p).Method(4).Type; tt != tfunc {
2411+
t.Errorf("Variadic Method Type from TypeOf is %s; want %s", tt, tfunc)
2412+
}
2413+
24082414
// Curried method of value.
2409-
tfunc := TypeOf((func(...Point) int)(nil))
2415+
tfunc = TypeOf((func(...Point) int)(nil))
24102416
v := ValueOf(p).Method(4)
24112417
if tt := v.Type(); tt != tfunc {
24122418
t.Errorf("Variadic Method Type is %s; want %s", tt, tfunc)

0 commit comments

Comments
 (0)