Chromium Code Reviews| 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. |