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

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

Issue 21085010: Added hasProperty matcher. (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 | « pkg/unittest/lib/mirror_matchers.dart ('k') | 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 * A useful utility class for implementing other matchers through inheritance. 842 * A useful utility class for implementing other matchers through inheritance.
843 * Derived classes should call the base constructor with a feature name and 843 * Derived classes should call the base constructor with a feature name and
844 * description, and an instance matcher, and should implement the 844 * description, and an instance matcher, and should implement the
845 * [featureValueOf] abstract method. 845 * [featureValueOf] abstract method.
846 * 846 *
847 * The feature description will typically describe the item and the feature, 847 * The feature description will typically describe the item and the feature,
848 * while the feature name will just name the feature. For example, we may 848 * while the feature name will just name the feature. For example, we may
849 * have a Widget class where each Widget has a price; we could make a 849 * have a Widget class where each Widget has a price; we could make a
850 * [CustomMatcher] that can make assertions about prices with: 850 * [CustomMatcher] that can make assertions about prices with:
851 * 851 *
852 <<<<<<< .mine
853 * class HasPrice extends CustomMatcher { 852 * class HasPrice extends CustomMatcher {
854 * const HasPrice(matcher) : 853 * const HasPrice(matcher) :
855 =======
856 * class HasPrice extends CustomMatcher {
857 * HasPrice(matcher) :
858 >>>>>>> .r25321
859 * super("Widget with price that is", "price", matcher); 854 * super("Widget with price that is", "price", matcher);
860 * featureValueOf(actual) => actual.price; 855 * featureValueOf(actual) => actual.price;
861 * } 856 * }
862 * 857 *
863 * and then use this for example like: 858 * and then use this for example like:
864 * 859 *
865 * expect(inventoryItem, new HasPrice(greaterThan(0))); 860 * expect(inventoryItem, new HasPrice(greaterThan(0)));
866 */ 861 */
867 class CustomMatcher extends Matcher { 862 class CustomMatcher extends Matcher {
868 final String _featureDescription; 863 final String _featureDescription;
(...skipping 22 matching lines...) Expand all
891 addDescriptionOf(matchState['feature']); 886 addDescriptionOf(matchState['feature']);
892 var innerDescription = new StringDescription(); 887 var innerDescription = new StringDescription();
893 _matcher.describeMismatch(matchState['feature'], innerDescription, 888 _matcher.describeMismatch(matchState['feature'], innerDescription,
894 matchState['state'], verbose); 889 matchState['state'], verbose);
895 if (innerDescription.length > 0) { 890 if (innerDescription.length > 0) {
896 mismatchDescription.add(' which ').add(innerDescription.toString()); 891 mismatchDescription.add(' which ').add(innerDescription.toString());
897 } 892 }
898 return mismatchDescription; 893 return mismatchDescription;
899 } 894 }
900 } 895 }
901
OLDNEW
« no previous file with comments | « pkg/unittest/lib/mirror_matchers.dart ('k') | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698