From: Cuong Manh Le Date: Wed, 22 Mar 2023 04:44:04 +0000 (+0700) Subject: reflect: add test for interface type NumMethod X-Git-Tag: go1.21rc1~1189 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=efaca3170fc6d363704153586c7ad94255bf02c6;p=gostls13.git reflect: add test for interface type NumMethod While at it, also use concrete type for non-interface type test. Change-Id: Ie468c30ee31ba99ef8f9a810d3be851fd37b9b43 Reviewed-on: https://go-review.googlesource.com/c/go/+/478356 Run-TryBot: Cuong Manh Le Reviewed-by: Ian Lance Taylor Auto-Submit: Cuong Manh Le TryBot-Result: Gopher Robot Reviewed-by: Keith Randall --- diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index c257bec1e5..31f6416ed9 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -3281,14 +3281,16 @@ type unexpI interface { f() (int32, int8) } -var unexpi unexpI = new(unexp) - func TestUnexportedMethods(t *testing.T) { - typ := TypeOf(unexpi) - + typ := TypeOf(new(unexp)) if got := typ.NumMethod(); got != 0 { t.Errorf("NumMethod=%d, want 0 satisfied methods", got) } + + typ = TypeOf((*unexpI)(nil)) + if got := typ.Elem().NumMethod(); got != 1 { + t.Errorf("NumMethod=%d, want 1 satisfied methods", got) + } } type InnerInt struct {