Files
sdk/pkg/analyzer_utilities/lib/testing/map_entry_matcher.dart
T
Sam Rawlins eaff33f439 analyzer_utilities: tidy static analysis
* Stop using `implicit-casts: false`
* Don't list rules which are found in package:lints
* Fix strict-inference issues

Change-Id: Ibe350548e3d6bef486ef2ef82430cda23d684baf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271780
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-11-28 18:11:03 +00:00

33 lines
1.0 KiB
Dart

// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:test/test.dart';
/// Matches a [MapEntry] with matching [MapEntry.key] and [MapEntry.value].
MapEntryMatcher isMapEntry(Object? key, Object? value) =>
MapEntryMatcher(key, value);
class MapEntryMatcher extends Matcher {
final Matcher keyMatcher;
final Matcher valueMatcher;
MapEntryMatcher(Object? key, Object? value)
: keyMatcher = wrapMatcher(key),
valueMatcher = wrapMatcher(value);
@override
Description describe(Description description) => description
.add('MapEntry(key: ')
.addDescriptionOf(keyMatcher)
.add(', value: ')
.addDescriptionOf(valueMatcher)
.add(')');
@override
bool matches(item, Map<dynamic, dynamic> matchState) =>
item is MapEntry &&
keyMatcher.matches(item.key, {}) &&
valueMatcher.matches(item.value, {});
}