]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: test that method name offset is valid
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 18 Apr 2016 08:50:19 +0000 (04:50 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Mon, 18 Apr 2016 19:13:36 +0000 (19:13 +0000)
Bug fix went in CL 21396, this is a matching test.

Fixes #15343

Change-Id: I3670145c7cac45cb4fb3121ffc039cfb7fa7c87a
Reviewed-on: https://go-review.googlesource.com/22171
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/reflect/all_test.go

index e1b26d9c68a80cbbc30d22482d7796b2c09deb60..4dfae2743d6114a22d7afc97691e80f4615df6f6 100644 (file)
@@ -5686,3 +5686,14 @@ func TestNameBytesAreAligned(t *testing.T) {
                t.Errorf("reflect.name.bytes pointer is not aligned: %x", v)
        }
 }
+
+func TestMethodPkgPathReadable(t *testing.T) {
+       // Reading the Method type for an unexported method triggers an
+       // offset resolution via p.name.pkgPath(). Make sure it uses a
+       // valid base pointer for the offset.
+       v := ValueOf(embed{})
+       m := v.Type().Method(0)
+       if m.PkgPath != "reflect" {
+               t.Errorf(`PkgPath=%q, want "reflect"`, m.PkgPath)
+       }
+}