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

Side by Side Diff: pkg/unittest/core_matchers.dart

Issue 11194025: Second round of cleanups for new optional parameter semantics. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * Returns a matcher that matches empty strings, maps or collections. 7 * Returns a matcher that matches empty strings, maps or collections.
8 */ 8 */
9 const Matcher isEmpty = const _Empty(); 9 const Matcher isEmpty = const _Empty();
10 10
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 const Throws([Matcher matcher]) : 274 const Throws([Matcher matcher]) :
275 this._matcher = matcher; 275 this._matcher = matcher;
276 276
277 bool matches(item, MatchState matchState) { 277 bool matches(item, MatchState matchState) {
278 if (item is Future) { 278 if (item is Future) {
279 // Queue up an asynchronous expectation that validates when the future 279 // Queue up an asynchronous expectation that validates when the future
280 // completes. 280 // completes.
281 item.onComplete(expectAsync1((future) { 281 item.onComplete(expectAsync1((future) {
282 if (future.hasValue) { 282 if (future.hasValue) {
283 expect(false, reason: 283 expect(false, isTrue,
284 "Expected future to fail, but succeeded with '${future.value}'."); 284 "Expected future to fail, but succeeded with '${future.value}'.");
285 } else if (_matcher != null) { 285 } else if (_matcher != null) {
286 var reason; 286 var reason;
287 if (future.stackTrace != null) { 287 if (future.stackTrace != null) {
288 var stackTrace = future.stackTrace.toString(); 288 var stackTrace = future.stackTrace.toString();
289 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; 289 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
290 reason = "Actual exception trace:\n$stackTrace"; 290 reason = "Actual exception trace:\n$stackTrace";
291 } 291 }
292 expect(future.exception, _matcher, reason: reason); 292 expect(future.exception, _matcher, reason);
293 } 293 }
294 })); 294 }));
295 295
296 // It hasn't failed yet. 296 // It hasn't failed yet.
297 return true; 297 return true;
298 } 298 }
299 299
300 try { 300 try {
301 item(); 301 item();
302 return false; 302 return false;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 final _matcher; 618 final _matcher;
619 final String _description; 619 final String _description;
620 620
621 const _Predicate(this._matcher, this._description); 621 const _Predicate(this._matcher, this._description);
622 622
623 bool matches(item, MatchState matchState) => _matcher(item); 623 bool matches(item, MatchState matchState) => _matcher(item);
624 624
625 Description describe(Description description) => 625 Description describe(Description description) =>
626 description.add(_description); 626 description.add(_description);
627 } 627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698