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

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

Issue 11821039: More fixes to unittest (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | pkg/unittest/lib/src/future_matchers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 collections. 8 * Returns a matcher that matches empty strings, maps or collections.
9 */ 9 */
10 const Matcher isEmpty = const _Empty(); 10 const Matcher isEmpty = const _Empty();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 bool matches(item, MatchState matchState) { 283 bool matches(item, MatchState matchState) {
284 if (item is Future) { 284 if (item is Future) {
285 var done = wrapAsync((fn) => fn()); 285 var done = wrapAsync((fn) => fn());
286 286
287 // Queue up an asynchronous expectation that validates when the future 287 // Queue up an asynchronous expectation that validates when the future
288 // completes. 288 // completes.
289 item.then((value) { 289 item.then((value) {
290 done(() => expect(false, isTrue, reason: 290 done(() => expect(false, isTrue, reason:
291 "Expected future to fail, but succeeded with '$value'.")); 291 "Expected future to fail, but succeeded with '$value'."));
292 }, onError: (e) { 292 }, onError: (e) {
293 var reason; 293 done(() {
294 if (e.stackTrace != null) { 294 if (_matcher == null) return;
295 var stackTrace = e.stackTrace.toString(); 295 var reason;
296 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; 296 if (e.stackTrace != null) {
297 reason = "Actual exception trace:\n$stackTrace"; 297 var stackTrace = e.stackTrace.toString();
298 } 298 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
299 done(() => expect(e.error, _matcher, reason: reason)); 299 reason = "Actual exception trace:\n$stackTrace";
300 }
301 expect(e.error, _matcher, reason: reason);
302 });
300 }); 303 });
301 304
302 // It hasn't failed yet. 305 // It hasn't failed yet.
303 return true; 306 return true;
304 } 307 }
305 308
306 try { 309 try {
307 item(); 310 item();
308 return false; 311 return false;
309 } catch (e, s) { 312 } catch (e, s) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); 680 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher);
678 681
679 Description describeMismatch(item, Description mismatchDescription, 682 Description describeMismatch(item, Description mismatchDescription,
680 MatchState matchState, bool verbose) { 683 MatchState matchState, bool verbose) {
681 mismatchDescription.add(_featureName).add(' '); 684 mismatchDescription.add(_featureName).add(' ');
682 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, 685 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription,
683 matchState.state['innerState'], verbose); 686 matchState.state['innerState'], verbose);
684 return mismatchDescription; 687 return mismatchDescription;
685 } 688 }
686 } 689 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/src/future_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698