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

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

Issue 18497014: Fixed documentation for CustomMatcher (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | no next file » | 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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 771
772 /** 772 /**
773 * A useful utility class for implementing other matchers through inheritance. 773 * A useful utility class for implementing other matchers through inheritance.
774 * Derived classes should call the base constructor with a feature name and 774 * Derived classes should call the base constructor with a feature name and
775 * description, and an instance matcher, and should implement the 775 * description, and an instance matcher, and should implement the
776 * [featureValueOf] abstract method. 776 * [featureValueOf] abstract method.
777 * 777 *
778 * The feature description will typically describe the item and the feature, 778 * The feature description will typically describe the item and the feature,
779 * while the feature name will just name the feature. For example, we may 779 * while the feature name will just name the feature. For example, we may
780 * have a Widget class where each Widget has a price; we could make a 780 * have a Widget class where each Widget has a price; we could make a
781 * FeatureMatcher that can make assertions about prices with: 781 * [CustomMatcher] that can make assertions about prices with:
782 * 782 *
783 * class HasPrice extends FeatureMatcher { 783 * class HasPrice extends CustomMatcher {
784 * const HasPrice(matcher) : 784 * HasPrice(matcher) :
785 * super("Widget with price that is", "price", matcher); 785 * super("Widget with price that is", "price", matcher);
786 * featureValueOf(actual) => actual.price; 786 * featureValueOf(actual) => actual.price;
787 * } 787 * }
788 * 788 *
789 * and then use this for example like: 789 * and then use this for example like:
790 * 790 *
791 * expect(inventoryItem, new HasPrice(greaterThan(0))); 791 * expect(inventoryItem, new HasPrice(greaterThan(0)));
792 */ 792 */
793 class CustomMatcher extends BaseMatcher { 793 class CustomMatcher extends BaseMatcher {
794 final String _featureDescription; 794 final String _featureDescription;
(...skipping 23 matching lines...) Expand all
818 var innerDescription = new StringDescription(); 818 var innerDescription = new StringDescription();
819 _matcher.describeMismatch(matchState['feature'], innerDescription, 819 _matcher.describeMismatch(matchState['feature'], innerDescription,
820 matchState['state'], verbose); 820 matchState['state'], verbose);
821 if (innerDescription.length > 0) { 821 if (innerDescription.length > 0) {
822 mismatchDescription.add(' which ').add(innerDescription.toString()); 822 mismatchDescription.add(' which ').add(innerDescription.toString());
823 } 823 }
824 return mismatchDescription; 824 return mismatchDescription;
825 } 825 }
826 } 826 }
827 827
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698