OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 scheduled_future_matchers; | 5 library scheduled_future_matchers; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 var matcherDescription = new StringDescription(); | 59 var matcherDescription = new StringDescription(); |
60 _matcher.describe(matcherDescription); | 60 _matcher.describe(matcherDescription); |
61 description = 'expect(..., completion($matcherDescription))'; | 61 description = 'expect(..., completion($matcherDescription))'; |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 var outerTrace = new Trace.current(); | 65 var outerTrace = new Trace.current(); |
66 currentSchedule.wrapFuture(item.then((value) { | 66 currentSchedule.wrapFuture(item.then((value) { |
67 if (_matcher == null) return; | 67 if (_matcher == null) return; |
68 | 68 |
69 try { | 69 // TODO(floitsch): we cannot switch traces anymore. |
70 expect(value, _matcher); | 70 // If expect throws we might want to be able to switch to the outer trace |
71 } catch (e, stackTrace) { | 71 // instead. |
72 throw new AsyncError(e, outerTrace); | 72 expect(value, _matcher); |
73 } | |
74 }), description); | 73 }), description); |
75 | 74 |
76 return true; | 75 return true; |
77 } | 76 } |
78 | 77 |
79 Description describe(Description description) { | 78 Description describe(Description description) { |
80 if (_matcher == null) { | 79 if (_matcher == null) { |
81 description.add('completes successfully'); | 80 description.add('completes successfully'); |
82 } else { | 81 } else { |
83 description.add('completes to a value that ').addDescriptionOf(_matcher); | 82 description.add('completes to a value that ').addDescriptionOf(_matcher); |
84 } | 83 } |
85 return description; | 84 return description; |
86 } | 85 } |
87 } | 86 } |
OLD | NEW |