| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |