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

Unified Diff: lib/unittest/expect.dart

Issue 10544167: Some unit test fixes (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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: lib/unittest/expect.dart
===================================================================
--- lib/unittest/expect.dart (revision 8732)
+++ lib/unittest/expect.dart (working copy)
@@ -33,7 +33,20 @@
* [dart-matchers] https://github.com/Ladicek/dart-matchers
*/
void expect(actual, [matcherOrReason = null, String reason = '']) {
eub 2012/06/15 21:02:49 BTW, I imagine you had prior review discussion of
gram 2012/06/15 21:25:55 Yes - the aim is to have just one expect(), but to
- if (matcherOrReason is Matcher) {
+ if (actual is bool &&
+ (matcherOrReason == null || matcherOrReason is String)) {
+ // Treat this as an assert(predicate, reason).
+ if (!actual) {
+ reason = (matcherOrReason == null) ? 'Assertion failed' : matcherOrReason;
+ // Make sure we have a failure handler configured.
+ configureExpectHandler(_assertFailureHandler);
+ _assertFailureHandler.fail(reason);
+ }
+ } else {
+ // Treat this as an expect(value, matcher, [reason]).
+ if (matcherOrReason is! Matcher) {
+ matcherOrReason = wrapMatcher(matcherOrReason);
+ }
var doesMatch;
try {
doesMatch = matcherOrReason.matches(actual);
@@ -48,13 +61,6 @@
configureExpectHandler(_assertFailureHandler);
_assertFailureHandler.failMatch(actual, matcherOrReason, reason);
}
- } else {
- if (!actual) {
- reason = (matcherOrReason == null) ? 'Assertion failed' : matcherOrReason;
- // Make sure we have a failure handler configured.
- configureExpectHandler(_assertFailureHandler);
- _assertFailureHandler.fail(reason);
- }
}
}

Powered by Google App Engine
This is Rietveld 408576698