dart-lang / matcher

A declarative API for specifying expectations.
https://pub.dev/packages/matcher
BSD 3-Clause "New" or "Revised" License
71 stars 37 forks source link

Add alternative matcher #207

Closed mosuem closed 1 year ago

mosuem commented 1 year ago

To support migrations, it is sometimes beneficial to have a matcher which allows for several true values as alternatives. While this is basically just a wrapper around anyOf, it is clearer in intent.

jakemac53 commented 1 year ago

What makes this clearer in intent than anyOf? I think anyOf is actually a better name...

I do see how it is less verbose for certain basic cases since you can specify a single matcher to use for all the values, but that also means that for more complicated cases you will have to fall back on anyOf. And you could always use map just like the implementation does to achieve a similar result with anyOf where you only specify the matcher once.

I do worry that this will lead to confusion over which to use, and I am not convinced too much of the benefit?

cc @natebosch wdyt?

mosuem commented 1 year ago

This is indeed too close to anyOf...