cmp/internal/funcion: allow different wrapper names (#403)

As of CL https://go-review.googlesource.com/c/go/+/790740, the name of
the wrapper function for (*myType).Write names the wrapped type
(bytes.Buffer.Write) instead of the wrapping type (function.myType.Write).

Modify the test to allow both before and after behaviors.

Co-authored-by: Joe Tsai <joetsai@digital-static.net>
diff --git a/cmp/internal/function/func_test.go b/cmp/internal/function/func_test.go
index eb87e9e..fa9cb40 100644
--- a/cmp/internal/function/func_test.go
+++ b/cmp/internal/function/func_test.go
@@ -21,29 +21,37 @@
 func TestNameOf(t *testing.T) {
 	tests := []struct {
 		fnc  any
-		want string
+		want []string // any matching entry is ok
 	}{
-		{TestNameOf, "function.TestNameOf"},
-		{func() {}, "function.TestNameOf.func1"},
-		{(myType).valueMethod, "function.myType.valueMethod"},
-		{(myType).ValueMethod, "function.myType.ValueMethod"},
-		{(myType{}).valueMethod, "function.myType.valueMethod"},
-		{(myType{}).ValueMethod, "function.myType.ValueMethod"},
-		{(*myType).valueMethod, "function.myType.valueMethod"},
-		{(*myType).ValueMethod, "function.myType.ValueMethod"},
-		{(&myType{}).valueMethod, "function.myType.valueMethod"},
-		{(&myType{}).ValueMethod, "function.myType.ValueMethod"},
-		{(*myType).pointerMethod, "function.myType.pointerMethod"},
-		{(*myType).PointerMethod, "function.myType.PointerMethod"},
-		{(&myType{}).pointerMethod, "function.myType.pointerMethod"},
-		{(&myType{}).PointerMethod, "function.myType.PointerMethod"},
-		{(*myType).Write, "function.myType.Write"},
-		{(&myType{}).Write, "bytes.Buffer.Write"},
+		{TestNameOf, []string{"function.TestNameOf"}},
+		{func() {}, []string{"function.TestNameOf.func1"}},
+		{(myType).valueMethod, []string{"function.myType.valueMethod"}},
+		{(myType).ValueMethod, []string{"function.myType.ValueMethod"}},
+		{(myType{}).valueMethod, []string{"function.myType.valueMethod"}},
+		{(myType{}).ValueMethod, []string{"function.myType.ValueMethod"}},
+		{(*myType).valueMethod, []string{"function.myType.valueMethod"}},
+		{(*myType).ValueMethod, []string{"function.myType.ValueMethod"}},
+		{(&myType{}).valueMethod, []string{"function.myType.valueMethod"}},
+		{(&myType{}).ValueMethod, []string{"function.myType.ValueMethod"}},
+		{(*myType).pointerMethod, []string{"function.myType.pointerMethod"}},
+		{(*myType).PointerMethod, []string{"function.myType.PointerMethod"}},
+		{(&myType{}).pointerMethod, []string{"function.myType.pointerMethod"}},
+		{(&myType{}).PointerMethod, []string{"function.myType.PointerMethod"}},
+		// Starting in Go 1.28, wrappers of embedded methods have the
+		// name of the wrapped type rather than the wrapping type.
+		{(*myType).Write, []string{"function.myType.Write", "bytes.Buffer.Write"}},
+		{(&myType{}).Write, []string{"bytes.Buffer.Write"}},
 	}
 	for _, tt := range tests {
 		t.Run("", func(t *testing.T) {
 			got := NameOf(reflect.ValueOf(tt.fnc))
-			if got != tt.want {
+			match := false
+			for _, w := range tt.want {
+				if got == w {
+					match = true
+				}
+			}
+			if !match {
 				t.Errorf("NameOf() = %v, want %v", got, tt.want)
 			}
 		})