@@ -87,14 +87,33 @@ func GotFormatterAdapter(s GotFormatter, m Matcher) Matcher {
87
87
}
88
88
}
89
89
90
- type anyMatcher struct {}
90
+ type anyMatcher struct {
91
+ matchers []Matcher
92
+ }
91
93
92
- func (anyMatcher ) Matches (interface {}) bool {
93
- return true
94
+ func (am anyMatcher ) Matches (x interface {}) bool {
95
+ if len (am .matchers ) == 0 {
96
+ return true
97
+ }
98
+
99
+ for _ , m := range am .matchers {
100
+ if m .Matches (x ) {
101
+ return true
102
+ }
103
+ }
104
+ return false
94
105
}
95
106
96
- func (anyMatcher ) String () string {
97
- return "is anything"
107
+ func (am anyMatcher ) String () string {
108
+ if len (am .matchers ) == 0 {
109
+ return "is anything"
110
+ }
111
+
112
+ ss := make ([]string , 0 , len (am .matchers ))
113
+ for _ , matcher := range am .matchers {
114
+ ss = append (ss , matcher .String ())
115
+ }
116
+ return strings .Join (ss , " OR " )
98
117
}
99
118
100
119
type eqMatcher struct {
@@ -273,12 +292,13 @@ func (m inAnyOrderMatcher) String() string {
273
292
274
293
// Constructors
275
294
276
- // All returns a composite Matcher that returns true if and only all of the
295
+ // All returns a composite Matcher that returns true if and only if all of the
277
296
// matchers return true.
278
297
func All (ms ... Matcher ) Matcher { return allMatcher {ms } }
279
298
280
- // Any returns a matcher that always matches.
281
- func Any () Matcher { return anyMatcher {} }
299
+ // All returns a composite Matcher that returns true if any of the
300
+ // matchers return true.
301
+ func Any (ms ... Matcher ) Matcher { return anyMatcher {ms } }
282
302
283
303
// Eq returns a matcher that matches on equality.
284
304
//
0 commit comments