]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: add test for variadic reflect.Type.Method
authorIan Lance Taylor <iant@golang.org>
Thu, 1 Oct 2020 21:55:11 +0000 (14:55 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 1 Oct 2020 22:23:53 +0000 (22:23 +0000)
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>
src/reflect/all_test.go

index abdfe4190841cbc4743bcabb74f1039bb6e3c5a4..ec87ec0c8a22c3cc1b5b7c3f24f47e4db5b3b2e8 100644 (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)