]> Cypherpunks.ru repositories - gostls13.git/commitdiff
reflect: add test that method values have the same code pointers
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 16 Oct 2021 18:18:20 +0000 (01:18 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 18 Oct 2021 16:32:38 +0000 (16:32 +0000)
Updates #40592

Change-Id: I16252dd57aceb5c49ddc11d8c12c601ca87ca902
Reviewed-on: https://go-review.googlesource.com/c/go/+/356252
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/reflect/all_test.go

index 8642d60f8b174134e9304556a8fe1ac500ceea18..0370906f7db6336be69222c4a60d2e3eb05d6e38 100644 (file)
@@ -2511,6 +2511,11 @@ func TestMethodValue(t *testing.T) {
        p := Point{3, 4}
        var i int64
 
+       // Check that method value have the same underlying code pointers.
+       if p1, p2 := ValueOf(Point{1, 1}).Method(1), ValueOf(Point{2, 2}).Method(1); p1.Pointer() != p2.Pointer() {
+               t.Errorf("methodValueCall mismatched: %v - %v", p1, p2)
+       }
+
        // Curried method of value.
        tfunc := TypeOf((func(int) int)(nil))
        v := ValueOf(p).Method(1)