| 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 library test.frontend.future_matchers; | 5 library test.frontend.future_matchers; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:matcher/matcher.dart' hide throws, throwsA, expect, fail; | 9 import 'package:matcher/matcher.dart' hide throws, throwsA, expect, fail; |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 }, onError: (error, trace) { | 53 }, onError: (error, trace) { |
| 54 if (error is TestFailure) { | 54 if (error is TestFailure) { |
| 55 Invoker.current.handleError(error, trace); | 55 Invoker.current.handleError(error, trace); |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 | 58 |
| 59 var id = _id == '' ? '' : '${_id} '; | 59 var id = _id == '' ? '' : '${_id} '; |
| 60 var reason = 'Expected future ${id}to complete successfully, ' | 60 var reason = 'Expected future ${id}to complete successfully, ' |
| 61 'but it failed with ${error}'; | 61 'but it failed with ${error}'; |
| 62 if (trace != null) { | 62 if (trace != null) { |
| 63 var stackTrace = terseChain(trace).toString(); | 63 var stackTrace = terseChain(trace, |
| 64 stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}'; | 64 verbose: Invoker.current.metadata.verboseTrace); |
| 65 stackTrace = ' ${stackTrace.toString().replaceAll('\n', '\n ')}'; |
| 65 reason = '$reason\nStack trace:\n$stackTrace'; | 66 reason = '$reason\nStack trace:\n$stackTrace'; |
| 66 } | 67 } |
| 67 fail(reason); | 68 fail(reason); |
| 68 }); | 69 }); |
| 69 | 70 |
| 70 return true; | 71 return true; |
| 71 } | 72 } |
| 72 | 73 |
| 73 Description describe(Description description) { | 74 Description describe(Description description) { |
| 74 if (_matcher == null) { | 75 if (_matcher == null) { |
| 75 description.add('completes successfully'); | 76 description.add('completes successfully'); |
| 76 } else { | 77 } else { |
| 77 description.add('completes to a value that ').addDescriptionOf(_matcher); | 78 description.add('completes to a value that ').addDescriptionOf(_matcher); |
| 78 } | 79 } |
| 79 return description; | 80 return description; |
| 80 } | 81 } |
| 81 } | 82 } |
| OLD | NEW |