@@ -436,35 +436,34 @@ class _IsSorted<T, K> extends _IterableMatcher<T> {
436
436
: _keyOf = keyOf,
437
437
_compare = compare;
438
438
439
- String ? _test (Iterable <T > item, Map matchState) {
439
+ @override
440
+ bool typedMatches (Iterable <T > item, Map matchState) {
440
441
var iterator = item.iterator;
441
- if (! iterator.moveNext ()) return null ;
442
+ if (! iterator.moveNext ()) return true ;
442
443
var previousElement = iterator.current;
443
444
var previousKey = _keyOf (previousElement);
444
445
while (iterator.moveNext ()) {
445
446
var element = iterator.current;
446
447
var key = _keyOf (element);
447
448
if (_compare (previousKey, key) > 0 ) {
448
- return StringDescription (
449
- 'found elements out of order: <$previousElement > and '
450
- '<$element >' )
451
- .toString ();
449
+ addStateInfo (matchState, {'first' : previousElement, 'second' : element});
450
+ return false ;
452
451
}
453
452
previousElement = element;
454
453
previousKey = key;
455
454
}
456
- return null ;
455
+ return true ;
457
456
}
458
457
459
- @override
460
- bool typedMatches (Iterable <T > item, Map matchState) =>
461
- _test (item, matchState) == null ;
462
-
463
458
@override
464
459
Description describe (Description description) => description.add ('is sorted' );
465
460
466
461
@override
467
462
Description describeTypedMismatch (Iterable <T > item,
468
463
Description mismatchDescription, Map matchState, bool verbose) =>
469
- mismatchDescription.add (_test (item, matchState)! );
464
+ mismatchDescription
465
+ .add ('found elements out of order: ' )
466
+ .addDescriptionOf (matchState['first' ])
467
+ .add (' and ' )
468
+ .addDescriptionOf (matchState['second' ]);
470
469
}
0 commit comments