@@ -760,18 +760,26 @@ const (
760760 Anything = "mock.Anything"
761761)
762762
763- // AnythingOfTypeArgument is a string that contains the type of an argument
763+ // AnythingOfTypeArgument contains the type of an argument
764764// for use when type checking. Used in Diff and Assert.
765- type AnythingOfTypeArgument string
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
770+ // for use when type checking. Used in Diff and Assert.
771+ type anythingOfTypeArgument string
766772
767- // AnythingOfType returns an AnythingOfTypeArgument object containing the
768- // 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.
769777//
770778// For example:
771779//
772780// Assert(t, AnythingOfType("string"), AnythingOfType("int"))
773781func AnythingOfType (t string ) AnythingOfTypeArgument {
774- return AnythingOfTypeArgument (t )
782+ return anythingOfTypeArgument (t )
775783}
776784
777785// IsTypeArgument is a struct that contains the type of an argument
@@ -952,9 +960,9 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
952960 differences ++
953961 output = fmt .Sprintf ("%s\t %d: FAIL: %s not matched by %s\n " , output , i , actualFmt , matcher )
954962 }
955- } else if reflect .TypeOf (expected ) == reflect .TypeOf ((* AnythingOfTypeArgument )(nil )).Elem () {
963+ } else if reflect .TypeOf (expected ) == reflect .TypeOf ((* anythingOfTypeArgument )(nil )).Elem () {
956964 // type checking
957- 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 )) {
958966 // not match
959967 differences ++
960968 output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , expected , reflect .TypeOf (actual ).Name (), actualFmt )
0 commit comments