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

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

Issue 14251006: Remove AsyncError with Expando. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 bool matches(item, MatchState matchState) { 320 bool matches(item, MatchState matchState) {
321 if (item is! Function && item is! Future) return false; 321 if (item is! Function && item is! Future) return false;
322 if (item is Future) { 322 if (item is Future) {
323 var done = wrapAsync((fn) => fn()); 323 var done = wrapAsync((fn) => fn());
324 324
325 // Queue up an asynchronous expectation that validates when the future 325 // Queue up an asynchronous expectation that validates when the future
326 // completes. 326 // completes.
327 item.then((value) { 327 item.then((value) {
328 done(() => fail("Expected future to fail, but succeeded with '$value'.") ); 328 done(() => fail("Expected future to fail, but succeeded with '$value'.") );
329 }, onError: (e) { 329 }, onError: (error) {
330 done(() { 330 done(() {
331 if (_matcher == null) return; 331 if (_matcher == null) return;
332 var reason; 332 var reason;
333 if (e.stackTrace != null) { 333 var trace = getAttachedStackTrace(error);
334 var stackTrace = e.stackTrace.toString(); 334 if (trace != null) {
335 var stackTrace = trace.toString();
335 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; 336 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
336 reason = "Actual exception trace:\n$stackTrace"; 337 reason = "Actual exception trace:\n$stackTrace";
337 } 338 }
338 expect(e.error, _matcher, reason: reason); 339 expect(error, _matcher, reason: reason);
339 }); 340 });
340 }); 341 });
341 // It hasn't failed yet. 342 // It hasn't failed yet.
342 return true; 343 return true;
343 } 344 }
344 345
345 try { 346 try {
346 item(); 347 item();
347 return false; 348 return false;
348 } catch (e, s) { 349 } catch (e, s) {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); 723 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher);
723 724
724 Description describeMismatch(item, Description mismatchDescription, 725 Description describeMismatch(item, Description mismatchDescription,
725 MatchState matchState, bool verbose) { 726 MatchState matchState, bool verbose) {
726 mismatchDescription.add(_featureName).add(' '); 727 mismatchDescription.add(_featureName).add(' ');
727 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, 728 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription,
728 matchState.state['innerState'], verbose); 729 matchState.state['innerState'], verbose);
729 return mismatchDescription; 730 return mismatchDescription;
730 } 731 }
731 } 732 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/value_future_test.dart ('k') | pkg/unittest/lib/src/future_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698