Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: pkg/unittest/lib/src/core_matchers.dart

Issue 20586002: Add matchers for some more recent error types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of matcher; 5 part of matcher;
6 6
7 /** 7 /**
8 * Returns a matcher that matches empty strings, maps or iterables 8 * Returns a matcher that matches empty strings, maps or iterables
9 * (including collections). 9 * (including collections).
10 */ 10 */
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 609
610 /** A matcher for functions that throw StateError. */ 610 /** A matcher for functions that throw StateError. */
611 const Matcher throwsStateError = 611 const Matcher throwsStateError =
612 const Throws(isStateError); 612 const Throws(isStateError);
613 613
614 class _StateError extends TypeMatcher { 614 class _StateError extends TypeMatcher {
615 const _StateError() : super("StateError"); 615 const _StateError() : super("StateError");
616 bool matches(item, Map matchState) => item is StateError; 616 bool matches(item, Map matchState) => item is StateError;
617 } 617 }
618 618
619 /** A matcher for FallThroughError. */
620 const isFallThroughError = const _FallThroughError();
621
622 /** A matcher for functions that throw FallThroughError. */
623 const Matcher throwsFallThroughError =
624 const Throws(isFallThroughError);
625
626 class _FallThroughError extends TypeMatcher {
627 const _FallThroughError() : super("FallThroughError");
628 bool matches(item, Map matchState) => item is FallThroughError;
629 }
630
631 /** A matcher for NullThrownError. */
632 const isNullThrownError = const _NullThrownError();
633
634 /** A matcher for functions that throw NullThrownError. */
635 const Matcher throwsNullThrownError =
636 const Throws(isNullThrownError);
637
638 class _NullThrownError extends TypeMatcher {
639 const _NullThrownError() : super("NullThrownError");
640 bool matches(item, Map matchState) => item is NullThrownError;
641 }
642
643 /** A matcher for ConcurrentModificationError. */
644 const isConcurrentModificationError = const _ConcurrentModificationError();
645
646 /** A matcher for functions that throw ConcurrentModificationError. */
647 const Matcher throwsConcurrentModificationError =
648 const Throws(isConcurrentModificationError);
649
650 class _ConcurrentModificationError extends TypeMatcher {
651 const _ConcurrentModificationError() : super("ConcurrentModificationError");
652 bool matches(item, Map matchState) => item is ConcurrentModificationError;
653 }
654
655 /** A matcher for AbstractClassInstantiationError. */
656 const isAbstractClassInstantiationError =
657 const _AbstractClassInstantiationError();
658
659 /** A matcher for functions that throw AbstractClassInstantiationError. */
660 const Matcher throwsAbstractClassInstantiationError =
661 const Throws(isAbstractClassInstantiationError);
662
663 class _AbstractClassInstantiationError extends TypeMatcher {
664 const _AbstractClassInstantiationError() :
665 super("AbstractClassInstantiationError");
666 bool matches(item, Map matchState) => item is AbstractClassInstantiationError;
667 }
668
669 /** A matcher for CyclicInitializationError. */
670 const isCyclicInitializationError = const _CyclicInitializationError();
671
672 /** A matcher for functions that throw CyclicInitializationError. */
673 const Matcher throwsCyclicInitializationError =
674 const Throws(isCyclicInitializationError);
675
676 class _CyclicInitializationError extends TypeMatcher {
677 const _CyclicInitializationError() : super("CyclicInitializationError");
678 bool matches(item, Map matchState) => item is CyclicInitializationError;
679 }
619 680
620 /** A matcher for Map types. */ 681 /** A matcher for Map types. */
621 const isMap = const _IsMap(); 682 const isMap = const _IsMap();
622 683
623 class _IsMap extends TypeMatcher { 684 class _IsMap extends TypeMatcher {
624 const _IsMap() : super("Map"); 685 const _IsMap() : super("Map");
625 bool matches(item, Map matchState) => item is Map; 686 bool matches(item, Map matchState) => item is Map;
626 } 687 }
627 688
628 /** A matcher for List types. */ 689 /** A matcher for List types. */
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 var innerDescription = new StringDescription(); 884 var innerDescription = new StringDescription();
824 _matcher.describeMismatch(matchState['feature'], innerDescription, 885 _matcher.describeMismatch(matchState['feature'], innerDescription,
825 matchState['state'], verbose); 886 matchState['state'], verbose);
826 if (innerDescription.length > 0) { 887 if (innerDescription.length > 0) {
827 mismatchDescription.add(' which ').add(innerDescription.toString()); 888 mismatchDescription.add(' which ').add(innerDescription.toString());
828 } 889 }
829 return mismatchDescription; 890 return mismatchDescription;
830 } 891 }
831 } 892 }
832 893
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698