| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 this._matcher = matcher; | 318 this._matcher = matcher; |
| 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(() => expect(false, isTrue, reason: | 328 done(() => fail("Expected future to fail, but succeeded with '$value'.")
); |
| 329 "Expected future to fail, but succeeded with '$value'.")); | |
| 330 }, onError: (e) { | 329 }, onError: (e) { |
| 331 done(() { | 330 done(() { |
| 332 if (_matcher == null) return; | 331 if (_matcher == null) return; |
| 333 var reason; | 332 var reason; |
| 334 if (e.stackTrace != null) { | 333 if (e.stackTrace != null) { |
| 335 var stackTrace = e.stackTrace.toString(); | 334 var stackTrace = e.stackTrace.toString(); |
| 336 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; | 335 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; |
| 337 reason = "Actual exception trace:\n$stackTrace"; | 336 reason = "Actual exception trace:\n$stackTrace"; |
| 338 } | 337 } |
| 339 expect(e.error, _matcher, reason: reason); | 338 expect(e.error, _matcher, reason: reason); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); | 722 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); |
| 724 | 723 |
| 725 Description describeMismatch(item, Description mismatchDescription, | 724 Description describeMismatch(item, Description mismatchDescription, |
| 726 MatchState matchState, bool verbose) { | 725 MatchState matchState, bool verbose) { |
| 727 mismatchDescription.add(_featureName).add(' '); | 726 mismatchDescription.add(_featureName).add(' '); |
| 728 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, | 727 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, |
| 729 matchState.state['innerState'], verbose); | 728 matchState.state['innerState'], verbose); |
| 730 return mismatchDescription; | 729 return mismatchDescription; |
| 731 } | 730 } |
| 732 } | 731 } |
| OLD | NEW |