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

Unified Diff: pkg/unittest/test/matchers_test.dart

Issue 11189040: Added a new Matcher, FeatureMatcher, that is a useful abstract base class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« pkg/unittest/core_matchers.dart ('K') | « pkg/unittest/core_matchers.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/test/matchers_test.dart
===================================================================
--- pkg/unittest/test/matchers_test.dart (revision 13752)
+++ pkg/unittest/test/matchers_test.dart (working copy)
@@ -23,6 +23,16 @@
add(' ignoring whitespace');
}
+class Widget {
+ int price;
+}
+
+class HasPrice extends FeatureMatcher {
+ const HasPrice(matcher) :
+ super("Widget with a price that is", "price", matcher);
+ featureValueOf(actual) => actual.price;
+}
+
void main() {
initUtils();
@@ -524,5 +534,16 @@
description: "an instance of String"));
});
});
+
+ group('Feature Matchers', () {
+ test("Feature Matcher", () {
+ var w = new Widget();
+ w.price = 10;
+ shouldPass(w, new HasPrice(greaterThan(0)));
+ shouldFail(w, new HasPrice(greaterThan(10)),
+ 'Expected: Widget with a price that is a value greater than <10> '
+ 'but: price was <10>.');
+ });
+ });
}
« pkg/unittest/core_matchers.dart ('K') | « pkg/unittest/core_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698