Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: pkg/scheduled_test/lib/src/scheduled_future_matchers.dart

Issue 13157004: Use the stack_trace library in scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule_error.dart ('k') | pkg/scheduled_test/lib/src/task.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
10
9 import '../scheduled_test.dart'; 11 import '../scheduled_test.dart';
10 12
11 /// Matches a [Future] that completes successfully with a value. Note that this 13 /// Matches a [Future] that completes successfully with a value. Note that this
12 /// creates an asynchronous expectation. The call to `expect()` that includes 14 /// creates an asynchronous expectation. The call to `expect()` that includes
13 /// this will return immediately and execution will continue. Later, when the 15 /// this will return immediately and execution will continue. Later, when the
14 /// future completes, the actual expectation will run. 16 /// future completes, the actual expectation will run.
15 /// 17 ///
16 /// To test that a Future completes with an exception, you can use [throws] and 18 /// To test that a Future completes with an exception, you can use [throws] and
17 /// [throwsA]. 19 /// [throwsA].
18 /// 20 ///
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (description == null) { 55 if (description == null) {
54 if (_matcher == null) { 56 if (_matcher == null) {
55 description = 'expect(..., completes)'; 57 description = 'expect(..., completes)';
56 } else { 58 } else {
57 var matcherDescription = new StringDescription(); 59 var matcherDescription = new StringDescription();
58 _matcher.describe(matcherDescription); 60 _matcher.describe(matcherDescription);
59 description = 'expect(..., completion($matcherDescription))'; 61 description = 'expect(..., completion($matcherDescription))';
60 } 62 }
61 } 63 }
62 64
65 var outerTrace = new Trace.current();
63 currentSchedule.wrapFuture(item.then((value) { 66 currentSchedule.wrapFuture(item.then((value) {
64 if (_matcher != null) expect(value, _matcher); 67 if (_matcher == null) return;
68
69 try {
70 expect(value, _matcher);
71 } catch (e, stackTrace) {
72 throw new AsyncError(e, outerTrace);
73 }
65 }), description); 74 }), description);
66 75
67 return true; 76 return true;
68 } 77 }
69 78
70 Description describe(Description description) { 79 Description describe(Description description) {
71 if (_matcher == null) { 80 if (_matcher == null) {
72 description.add('completes successfully'); 81 description.add('completes successfully');
73 } else { 82 } else {
74 description.add('completes to a value that ').addDescriptionOf(_matcher); 83 description.add('completes to a value that ').addDescriptionOf(_matcher);
75 } 84 }
76 return description; 85 return description;
77 } 86 }
78 } 87 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule_error.dart ('k') | pkg/scheduled_test/lib/src/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698