contains() should auto-wrap in a matcher
- Dominant language
- Dart
- Stars
- 536
- Forks
- 232
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 10
Description
Use case:
```dart
expect(fontManifest, contains({
'family': 'DummyFont',
'fonts': [
{'asset': 'fonts/dummy_font_regular'},
{'asset': 'fonts/dummy_font_bold', 'weight': 600},
{'asset': 'fonts/dummy_font_italic', 'style': 'italic'},
{'asset': 'fonts/dummy_font_bold_italic', 'weight': 600, 'style': 'italic'},
],
}));
```
Right now, this doesn't work, and the user has to explicitly call `wrapMatcher()` to get the desired behavior:
```dart
expect(fontManifest, contains(wrapMatcher({
'family': 'DummyFont',
'fonts': [
{'asset': 'fonts/dummy_font_regular'},
{'asset': 'fonts/dummy_font_bold', 'weight': 600},
{'asset': 'fonts/dummy_font_italic', 'style': 'italic'},
{'asset': 'fonts/dummy_font_bold_italic', 'weight': 600, 'style': 'italic'},
],
})));
```
It'd be more elegant if [`contains()`](https://github.com/dart-lang/matcher/blob/be1ccacf140d77e33a11a0393a3e054dc069c89f/lib/src/core_matchers.dart#L514) implicitly called `wrapMatcher()` if it were matching against a non-string value.
Contributor guide
Research direction
Start in lib/src/core_matchers.dart at contains() and compare its current behavior with wrapMatcher(). Run the relevant matcher tests, then verify that contains() accepts the shown non-string map value without an explicit wrapMatcher() while preserving existing string-matching behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100