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

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

Issue 184103002: Support nested matchers in deep equality matching. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
Index: pkg/unittest/test/matchers_test.dart
diff --git a/pkg/unittest/test/matchers_test.dart b/pkg/unittest/test/matchers_test.dart
index 9f8e121944b59f8fcb564ca5808fa769121c4cbc..8678966b11227c7ffdfd660b6e70a6f95f0a55f6 100644
--- a/pkg/unittest/test/matchers_test.dart
+++ b/pkg/unittest/test/matchers_test.dart
@@ -401,6 +401,15 @@ void main() {
"Actual: [1, 2]");
});
+ test('equals with matcher element', () {
+ var d = ['foo', 'bar'];
+ shouldPass(d, equals(['foo', startsWith('ba')]));
+ shouldFail(d, equals(['foo', endsWith('ba')]),
+ "Expected: ['foo', <a string ending with 'ba'>] "
+ "Actual: ['foo', 'bar'] "
+ "Which: does not match a string ending with 'ba' at location [1]");
+ });
+
test('isIn', () {
var d = [1, 2];
shouldPass(1, isIn(d));
@@ -593,6 +602,16 @@ void main() {
"Which: has different length and is missing map key 'foo'");
});
+ test('equals with matcher value', () {
+ var a = new Map();
+ a['foo'] = 'bar';
+ shouldPass(a, equals({'foo': startsWith('ba')}));
+ shouldFail(a, equals({'foo': endsWith('ba')}),
+ "Expected: {'foo': <a string ending with 'ba'>} "
+ "Actual: {'foo': 'bar'} "
+ "Which: does not match a string ending with 'ba' at location ['foo']");
Siggi Cherem (dart-lang) 2014/02/28 02:41:04 80 col
Bob Nystrom 2014/02/28 17:31:24 Done.
+ });
+
test('contains', () {
var a = new Map();
a['foo'] = 'bar';

Powered by Google App Engine
This is Rietveld 408576698