@@ -12,9 +12,10 @@ import (
1212 "time"
1313
1414 "github.com/davecgh/go-spew/spew"
15+ "github.com/pmezard/go-difflib/difflib"
1516 "github.com/stretchr/objx"
17+
1618 "github.com/stretchr/testify/assert"
17- "github.com/stretchr/testify/internal/difflib"
1819)
1920
2021// regex for GCCGO functions
@@ -603,12 +604,11 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool {
603604 h .Helper ()
604605 }
605606 for _ , obj := range testObjects {
606- m , ok := obj .(assertExpectationiser )
607- if ! ok {
608- t .Errorf ("Invalid test object type %T. Expected reference to a mock.Mock, eg: 'AssertExpectationsForObjects(t, myMock)' or 'AssertExpectationsForObjects(t, &myMock.Mock)'" , obj )
609- continue
610-
607+ if m , ok := obj .(* Mock ); ok {
608+ t .Logf ("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)" )
609+ obj = m
611610 }
611+ m := obj .(assertExpectationiser )
612612 if ! m .AssertExpectations (t ) {
613613 t .Logf ("Expectations didn't match for Mock: %+v" , reflect .TypeOf (m ))
614614 return false
@@ -712,8 +712,8 @@ func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...inter
712712 return true
713713}
714714
715- // IsMethodCallable returns true if given methodName and arguments have an
716- // unsatisfied expected call registered in the Mock.
715+ // IsMethodCallable checking that the method can be called
716+ // If the method was called more than `Repeatability` return false
717717func (m * Mock ) IsMethodCallable (t TestingT , methodName string , arguments ... interface {}) bool {
718718 if h , ok := t .(tHelper ); ok {
719719 h .Helper ()
@@ -833,10 +833,6 @@ type IsTypeArgument struct {
833833// For example:
834834//
835835// args.Assert(t, IsType(""), IsType(0))
836- //
837- // Mock cannot match interface types because the contained type will be passed
838- // to both IsType and Mock.Called, for the zero value of all interfaces this
839- // will be <nil> type.
840836func IsType (t interface {}) * IsTypeArgument {
841837 return & IsTypeArgument {t : reflect .TypeOf (t )}
842838}
@@ -1016,7 +1012,7 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
10161012 actualT := reflect .TypeOf (actual )
10171013 if actualT != expected .t {
10181014 differences ++
1019- output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , safeTypeName ( expected .t ), safeTypeName ( actualT ), actualFmt )
1015+ output = fmt .Sprintf ("%s\t %d: FAIL: type %s != type %s - %s\n " , output , i , expected .t . Name ( ), actualT . Name ( ), actualFmt )
10201016 }
10211017 case * FunctionalOptionsArgument :
10221018 var name string
@@ -1145,15 +1141,6 @@ func (args Arguments) Bool(index int) bool {
11451141 return s
11461142}
11471143
1148- // safeTypeName returns the reflect.Type's name without causing a panic.
1149- // If the provided reflect.Type is nil, it returns the placeholder string "<nil>"
1150- func safeTypeName (t reflect.Type ) string {
1151- if t == nil {
1152- return "<nil>"
1153- }
1154- return t .Name ()
1155- }
1156-
11571144func typeAndKind (v interface {}) (reflect.Type , reflect.Kind ) {
11581145 t := reflect .TypeOf (v )
11591146 k := t .Kind ()
0 commit comments