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

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

Issue 15017013: Added a new matcher for pairwise comparison of iterables with a custom comparator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
« no previous file with comments | « pkg/unittest/lib/src/iterable_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 22469)
+++ pkg/unittest/test/matchers_test.dart (working copy)
@@ -523,6 +523,27 @@
"Expected: equals <[3, 1]> unordered "
"but: has no match for element <3> at position 0.");
});
+
+ test('pairwise compare', () {
+ var c = [1, 2];
+ var d = [1, 2, 3];
+ var e = [1, 4, 9];
+ shouldFail('x', pairwiseCompare(e, (e,a) => a <= e,
+ "less than or equal"),
+ "Expected: pairwise less than or equal <[1, 4, 9]> but: "
+ "not an Iterable.");
+ shouldFail(c, pairwiseCompare(e, (e,a) => a <= e, "less than or equal"),
+ "Expected: pairwise less than or equal <[1, 4, 9]> but: "
+ "length was 2 instead of 3.");
+ shouldPass(d, pairwiseCompare(e, (e,a) => a <= e, "less than or equal"));
+ shouldFail(d, pairwiseCompare(e, (e,a) => a < e, "less than"),
+ "Expected: pairwise less than <[1, 4, 9]> but: "
+ "<1> not less than <1> at position 0.");
+ shouldPass(d, pairwiseCompare(e, (e,a) => a * a == e, "square root of"));
+ shouldFail(d, pairwiseCompare(e, (e,a) => a + a == e, "double"),
+ "Expected: pairwise double <[1, 4, 9]> but: "
+ "<1> not double <1> at position 0.");
+ });
});
group('Map Matchers', () {
« no previous file with comments | « pkg/unittest/lib/src/iterable_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698