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

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

Issue 48483002: Remove deprecated parts of dart:async. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 7 years, 1 month 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 part of matcher; 5 part of matcher;
6 6
7 /** 7 /**
8 * Returns a matcher that matches empty strings, maps or iterables 8 * Returns a matcher that matches empty strings, maps or iterables
9 * (including collections). 9 * (including collections).
10 */ 10 */
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 bool matches(item, Map matchState) { 412 bool matches(item, Map matchState) {
413 if (item is! Function && item is! Future) return false; 413 if (item is! Function && item is! Future) return false;
414 if (item is Future) { 414 if (item is Future) {
415 var done = wrapAsync((fn) => fn()); 415 var done = wrapAsync((fn) => fn());
416 416
417 // Queue up an asynchronous expectation that validates when the future 417 // Queue up an asynchronous expectation that validates when the future
418 // completes. 418 // completes.
419 item.then((value) { 419 item.then((value) {
420 done(() => fail("Expected future to fail, but succeeded with '$value'.") ); 420 done(() => fail("Expected future to fail, but succeeded with '$value'.") );
421 }, onError: (error) { 421 }, onError: (error, trace) {
422 done(() { 422 done(() {
423 if (_matcher == null) return; 423 if (_matcher == null) return;
424 var reason; 424 var reason;
425 var trace = getAttachedStackTrace(error);
426 if (trace != null) { 425 if (trace != null) {
427 var stackTrace = trace.toString(); 426 var stackTrace = trace.toString();
428 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; 427 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
429 reason = "Actual exception trace:\n$stackTrace"; 428 reason = "Actual exception trace:\n$stackTrace";
430 } 429 }
431 expect(error, _matcher, reason: reason); 430 expect(error, _matcher, reason: reason);
432 }); 431 });
433 }); 432 });
434 // It hasn't failed yet. 433 // It hasn't failed yet.
435 return true; 434 return true;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 addDescriptionOf(matchState['feature']); 885 addDescriptionOf(matchState['feature']);
887 var innerDescription = new StringDescription(); 886 var innerDescription = new StringDescription();
888 _matcher.describeMismatch(matchState['feature'], innerDescription, 887 _matcher.describeMismatch(matchState['feature'], innerDescription,
889 matchState['state'], verbose); 888 matchState['state'], verbose);
890 if (innerDescription.length > 0) { 889 if (innerDescription.length > 0) {
891 mismatchDescription.add(' which ').add(innerDescription.toString()); 890 mismatchDescription.add(' which ').add(innerDescription.toString());
892 } 891 }
893 return mismatchDescription; 892 return mismatchDescription;
894 } 893 }
895 } 894 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule_error.dart ('k') | pkg/unittest/lib/src/future_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698