mirror of https://github.com/stretchr/testify.git
Introduce unexported match method to report errors matching
Changes to the method signature for argumentMatcher.Matches may lead to breaking existing external uses of that function. Introducing a new method used internally allows presenting the error information out for internal testify functionality while not breaking other existing uses of Matches.pull/639/head
parent
b59ea01145
commit
42afde47af
|
@ -580,7 +580,11 @@ type argumentMatcher struct {
|
|||
fn reflect.Value
|
||||
}
|
||||
|
||||
func (f argumentMatcher) Matches(argument interface{}) error {
|
||||
func (f argumentMatcher) Matches(argument interface{}) bool {
|
||||
return f.match(argument) == nil
|
||||
}
|
||||
|
||||
func (f argumentMatcher) match(argument interface{}) error {
|
||||
expectType := f.fn.Type().In(0)
|
||||
expectTypeNilSupported := false
|
||||
switch expectType.Kind() {
|
||||
|
@ -718,7 +722,7 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
|
|||
}
|
||||
|
||||
if matcher, ok := expected.(argumentMatcher); ok {
|
||||
if matchError := matcher.Matches(actual); matchError == nil {
|
||||
if matchError := matcher.match(actual); matchError == nil {
|
||||
output = fmt.Sprintf("%s\t%d: PASS: %s matched by %s\n", output, i, actualFmt, matcher)
|
||||
} else {
|
||||
differences++
|
||||
|
|
Loading…
Reference in New Issue