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

Unified Diff: pkg/unittest/lib/src/core_matchers.dart

Issue 12217142: Unit test improvements: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « no previous file | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/core_matchers.dart
===================================================================
--- pkg/unittest/lib/src/core_matchers.dart (revision 18358)
+++ pkg/unittest/lib/src/core_matchers.dart (working copy)
@@ -172,15 +172,23 @@
}
}
} else {
+ reason = new StringDescription();
+ var includeTypes = expected.runtimeType != actual.runtimeType;
// If we have recursed, show the expected value too; if not,
- // expect() will show it for us.
- reason = new StringDescription();
- if (depth > 1) {
- reason.add('expected ').addDescriptionOf(expected).add(' but was ').
- addDescriptionOf(actual);
- } else {
- reason.add('was ').addDescriptionOf(actual);
+ // expect() will show it for us. As expect will not show type
+ // mismatches at the top level we handle those here too.
+ if (includeTypes || depth > 1) {
+ reason.add('expected ');
+ if (includeTypes) {
+ reason..add(expected.runtimeType).add(':');
+ }
+ reason.addDescriptionOf(expected).add(' but ');
}
+ reason.add('was ');
+ if (includeTypes) {
+ reason..add(actual.runtimeType).add(':');
+ }
+ reason.addDescriptionOf(actual);
}
}
if (reason != null && location.length > 0) {
@@ -320,6 +328,8 @@
// It hasn't failed yet.
return true;
+ } else if (item is! Function) {
+ return false;
Siggi Cherem (dart-lang) 2013/02/12 20:48:51 nit: given that this is fast-exit code, it might b
gram 2013/02/12 20:59:30 Done.
}
try {
@@ -350,7 +360,9 @@
Description describeMismatch(item, Description mismatchDescription,
MatchState matchState,
bool verbose) {
- if (_matcher == null || matchState.state == null) {
+ if (item is! Function && item is! Future) {
+ return mismatchDescription.add(' not a Function or Future');
+ } else if (_matcher == null || matchState.state == null) {
return mismatchDescription.add(' no exception');
} else {
mismatchDescription.
« no previous file with comments | « no previous file | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698