| 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 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 class Throws extends BaseMatcher { | 277 class Throws extends BaseMatcher { |
| 278 final Matcher _matcher; | 278 final Matcher _matcher; |
| 279 | 279 |
| 280 const Throws([Matcher matcher]) : | 280 const Throws([Matcher matcher]) : |
| 281 this._matcher = matcher; | 281 this._matcher = matcher; |
| 282 | 282 |
| 283 bool matches(item, MatchState matchState) { | 283 bool matches(item, MatchState matchState) { |
| 284 if (item is Future) { | 284 if (item is Future) { |
| 285 // Queue up an asynchronous expectation that validates when the future | 285 // Queue up an asynchronous expectation that validates when the future |
| 286 // completes. | 286 // completes. |
| 287 item.then((value) { | 287 item.then(wrapAsync((value) { |
| 288 expect(false, isTrue, reason: | 288 expect(false, isTrue, reason: |
| 289 "Expected future to fail, but succeeded with '$value'."); | 289 "Expected future to fail, but succeeded with '$value'."); |
| 290 }); | 290 })); |
| 291 | 291 |
| 292 item.catchError((e) { | 292 item.catchError((e) { |
| 293 var reason; | 293 var reason; |
| 294 if (e.stackTrace != null) { | 294 if (e.stackTrace != null) { |
| 295 var stackTrace = e.stackTrace.toString(); | 295 var stackTrace = e.stackTrace.toString(); |
| 296 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; | 296 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; |
| 297 reason = "Actual exception trace:\n$stackTrace"; | 297 reason = "Actual exception trace:\n$stackTrace"; |
| 298 } | 298 } |
| 299 expect(e.error, _matcher, reason: reason); | 299 expect(e.error, _matcher, reason: reason); |
| 300 }); | 300 }); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); | 677 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); |
| 678 | 678 |
| 679 Description describeMismatch(item, Description mismatchDescription, | 679 Description describeMismatch(item, Description mismatchDescription, |
| 680 MatchState matchState, bool verbose) { | 680 MatchState matchState, bool verbose) { |
| 681 mismatchDescription.add(_featureName).add(' '); | 681 mismatchDescription.add(_featureName).add(' '); |
| 682 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, | 682 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, |
| 683 matchState.state['innerState'], verbose); | 683 matchState.state['innerState'], verbose); |
| 684 return mismatchDescription; | 684 return mismatchDescription; |
| 685 } | 685 } |
| 686 } | 686 } |
| OLD | NEW |