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

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

Issue 14367005: Improved error messages for type mismatches. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/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 21707)
+++ pkg/unittest/test/matchers_test.dart (working copy)
@@ -237,21 +237,26 @@
shouldPass(b, hasLength(2));
});
- test('type mismatch', () {
- var a = new DateTime.utc(2000);
- var b = a.toString();
- // We should get something like:
- // Expected: '2000-01-01 00:00:00.000Z'
- // but: expected String:'2000-01-01 00:00:00.000Z'
- // but was DateTime:<2000-01-01 00:00:00.000Z>.
- // However, if minification is applied, then the type names
- // will be shortened to two letters. The key thing is that
- // there will be a "but: expected" part in the middle;
- // this only happens with type mismatches or mismatches
- // inside container types.
- shouldFail(a, equals(b),
- matches(new RegExp("^Expected.*but: expected .*but was.*\$")));
+ test('scalar type mismatch', () {
+ shouldFail('error', equals(5.0),
+ matches("^Expected: <5\.0>"
+ " but: was .*:'error' \\(not type .*\\)\.\$"));
Siggi Cherem (dart-lang) 2013/04/19 17:18:24 now that is shorter, can we spell it out here? "
});
+
+ test('nested type mismatch', () {
+ shouldFail(['error'], equals([5.0]),
+ matches(r"^Expected: <\[5\.0\]>"
+ " but: expected double:<5\.0> "
+ "but was .*:'error' mismatch at position 0\.\$"));
+ });
+
+ test('doubly-nested type mismatch', () {
+ shouldFail([['error']], equals([[5.0]]),
+ matches(r"^Expected: <\[\[5\.0\]\]>"
+ " but: expected double:<5\.0> "
+ "but was .*:'error' mismatch at position 0 "
+ "mismatch at position 0\.\$"));
+ });
});
group('Numeric Matchers', () {
@@ -502,7 +507,7 @@
shouldPass(d, orderedEquals([1, 2]));
shouldFail(d, orderedEquals([2, 1]),
"Expected: equals <[2, 1]> ordered "
- "but: was <1> mismatch at position 0.");
+ "but: expected <2> but was <1> mismatch at position 0.");
});
test('unorderedEquals', () {
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698