matches method
Does the matching of the actual vs expected values.
item
is the actual value. matchState
can be supplied
and may be used to add details about the mismatch that are too
costly to determine in describeMismatch.
Implementation
@override
bool matches(dynamic item, Map matchState) {
final expectedLength = expected.length;
final actualLength = item.length;
if (expectedLength != actualLength) {
addStateInfo(matchState, {
'length.actual': actualLength,
'length.expected': expectedLength,
'length.mismatch': true,
});
return false;
}
// try {
// if (_expected.length != delta.length) {
// throw ErrorOf<Matcher>(
// message: 'Error using matcher \'orderedCloseTo()\'',
// invalidState: 'Arguments expected: $_expected and '
// 'delta: $delta have different length.');
// }
// } catch (exception, stack) {
// addStateInfo(matchState, {
// 'length.delta': delta1.length,
// 'delta.exception': exception.toString(),
// 'delta.stack': stack.toString(),
// });
// }
final actIt = item.iterator;
final expIt = expected.iterator;
var i = 0;
while (actIt.moveNext() && expIt.moveNext()) {
if ((actIt.current - expIt.current).abs() <= delta) {
} else {
addStateInfo(matchState, {
'mismatchAtPosition': i,
'actualAtPosition': actIt.current,
'expectedAtPosition': expIt.current,
'delta': delta,
});
return false;
}
++i;
}
return true;
}