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

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

Issue 112583003: Add an [unorderedMatches] matcher to unittest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/pubspec.yaml ('K') | « pkg/unittest/pubspec.yaml ('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
diff --git a/pkg/unittest/test/matchers_test.dart b/pkg/unittest/test/matchers_test.dart
index 1ec1e92d59ee788371629ca0f250529b501c0f29..daa39bd01b964214196e385f081cff0805ff839d 100644
--- a/pkg/unittest/test/matchers_test.dart
+++ b/pkg/unittest/test/matchers_test.dart
@@ -484,6 +484,29 @@ void main() {
"Which: has no match for element <3> at index 0");
});
+ test('unorderedMatchess', () {
+ var d = [1, 2];
+ shouldPass(d, unorderedMatches([2, 1]));
+ shouldPass(d, unorderedMatches([greaterThan(1), greaterThan(0)]));
+ shouldFail(d, unorderedMatches([greaterThan(0)]),
+ "Expected: matches [a value greater than <0>] unordered "
+ "Actual: [1, 2] "
+ "Which: has too many elements (2 > 1)");
+ shouldFail(d, unorderedMatches([3, 2, 1]),
+ "Expected: matches [<3>, <2>, <1>] unordered "
+ "Actual: [1, 2] "
+ "Which: has too few elements (2 < 3)");
+ shouldFail(d, unorderedMatches([3, 1]),
+ "Expected: matches [<3>, <1>] unordered "
+ "Actual: [1, 2] "
+ "Which: has no match for <3> at index 0");
+ shouldFail(d, unorderedMatches([greaterThan(3), greaterThan(0)]),
+ "Expected: matches [a value greater than <3>, a value greater than "
+ "<0>] unordered "
+ "Actual: [1, 2] "
+ "Which: has no match for a value greater than <3> at index 0");
+ });
+
test('pairwise compare', () {
var c = [1, 2];
var d = [1, 2, 3];
« pkg/unittest/pubspec.yaml ('K') | « pkg/unittest/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698