@@ -18,6 +18,9 @@ import (
1818 "github.com/stretchr/testify/assert"
1919)
2020
21+ // regex for GCCGO functions
22+ var gccgoRE = regexp .MustCompile (`\.pN\d+_` )
23+
2124// TestingT is an interface wrapper around *testing.T
2225type TestingT interface {
2326 Logf (format string , args ... interface {})
@@ -455,9 +458,8 @@ func (m *Mock) Called(arguments ...interface{}) Arguments {
455458 // For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
456459 // uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
457460 // With GCCGO we need to remove interface information starting from pN<dd>.
458- re := regexp .MustCompile ("\\ .pN\\ d+_" )
459- if re .MatchString (functionPath ) {
460- functionPath = re .Split (functionPath , - 1 )[0 ]
461+ if gccgoRE .MatchString (functionPath ) {
462+ functionPath = gccgoRE .Split (functionPath , - 1 )[0 ]
461463 }
462464 parts := strings .Split (functionPath , "." )
463465 functionName := parts [len (parts )- 1 ]
@@ -758,18 +760,26 @@ const (
758760 Anything = "mock.Anything"
759761)
760762
761- // AnythingOfTypeArgument is a string that contains the type of an argument
763+ // AnythingOfTypeArgument contains the type of an argument
764+ // for use when type checking. Used in Diff and Assert.
765+ //
766+ // Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead.
767+ type AnythingOfTypeArgument = anythingOfTypeArgument
768+
769+ // anythingOfTypeArgument is a string that contains the type of an argument
762770// for use when type checking. Used in Diff and Assert.
763- type AnythingOfTypeArgument string
771+ type anythingOfTypeArgument string
764772
765- // AnythingOfType returns an AnythingOfTypeArgument object containing the
766- // name of the type to check for. Used in Diff and Assert.
773+ // AnythingOfType returns a special value containing the
774+ // name of the type to check for. The type name will be matched against the type name returned by [reflect.Type.String].
775+ //
776+ // Used in Diff and Assert.
767777//
768778// For example:
769779//
770780// Assert(t, AnythingOfType("string"), AnythingOfType("int"))
771781func AnythingOfType (t string ) AnythingOfTypeArgument {
772- return AnythingOfTypeArgument (t )
782+ return anythingOfTypeArgument (t )
773783}
774784
775785// IsTypeArgument is a struct that contains the type of an argument
@@ -950,9 +960,9 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
950960 differences ++
951961 output = fmt .Sprintf ("%s\t %d: FAIL: %s not matched by %s\n " , output , i , actualFmt , matcher )
952962 }
953- } else if reflect .TypeOf (expected ) == reflect .TypeOf ((* AnythingOfTypeArgument )(nil )).Elem () {
963+ } else if reflect .TypeOf (expected ) == reflect .TypeOf ((* anythingOfTypeArgument )(nil )).Elem () {
954964 // type checking
955- if reflect .TypeOf (actual ).Name () != string (expected .(AnythingOfTypeArgument )) && reflect .TypeOf (actual ).String () != string (expected .(AnythingOfTypeArgument )) {
965+ if reflect .TypeOf (actual ).Name () != string (expected .(anythingOfTypeArgument )) && reflect .TypeOf (actual ).String () != string (expected .(anythingOfTypeArgument )) {
956966 // not match
957967 differences ++
958968 output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , expected , reflect .TypeOf (actual ).Name (), actualFmt )
0 commit comments