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

Side by Side Diff: pkg/unittest/lib/src/spread_args_helper.dart

Issue 130173010: pkg/unittest: Run each test in a Zone (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: TODO for explaining async error in a more clear way Created 6 years, 10 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/unittest/CHANGELOG.md ('k') | pkg/unittest/lib/unittest.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 part of unittest; 1 part of unittest;
2 2
3 /** Simulates spread arguments using named arguments. */ 3 /** Simulates spread arguments using named arguments. */
4 // TODO(sigmund): remove this class and simply use a closure with named 4 // TODO(sigmund): remove this class and simply use a closure with named
5 // arguments (if still applicable). 5 // arguments (if still applicable).
6 class _SpreadArgsHelper { 6 class _SpreadArgsHelper {
7 final Function callback; 7 final Function callback;
8 final int minExpectedCalls; 8 final int minExpectedCalls;
9 final int maxExpectedCalls; 9 final int maxExpectedCalls;
10 final Function isDone; 10 final Function isDone;
11 final String id; 11 final String id;
12 int actualCalls = 0; 12 int actualCalls = 0;
13 final TestCase testCase; 13 final TestCase testCase;
14 bool complete; 14 bool complete;
15 static const sentinel = const _Sentinel();
16 15
17 _SpreadArgsHelper(Function callback, int minExpected, int maxExpected, 16 _SpreadArgsHelper(Function callback, int minExpected, int maxExpected,
18 Function isDone, String id) 17 Function isDone, String id)
19 : this.callback = callback, 18 : this.callback = callback,
20 minExpectedCalls = minExpected, 19 minExpectedCalls = minExpected,
21 maxExpectedCalls = (maxExpected == 0 && minExpected > 0) 20 maxExpectedCalls = (maxExpected == 0 && minExpected > 0)
22 ? minExpected 21 ? minExpected
23 : maxExpected, 22 : maxExpected,
24 this.isDone = isDone, 23 this.isDone = isDone,
25 this.testCase = currentTestCase, 24 this.testCase = currentTestCase,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 112
114 invoke2(arg1, arg2) { 113 invoke2(arg1, arg2) {
115 return _guardAsync( 114 return _guardAsync(
116 () { 115 () {
117 if (shouldCallBack()) { 116 if (shouldCallBack()) {
118 return callback(arg1, arg2); 117 return callback(arg1, arg2);
119 } 118 }
120 }, 119 },
121 after, testCase); 120 after, testCase);
122 } 121 }
122
123 _guardAsync(Function tryBody, Function finallyBody, TestCase testCase) {
124 assert(testCase != null);
125 try {
126 return tryBody();
127 } catch (e, trace) {
128 _registerException(testCase, e, trace);
129 } finally {
130 if (finallyBody != null) finallyBody();
131 }
132 }
123 } 133 }
OLDNEW
« no previous file with comments | « pkg/unittest/CHANGELOG.md ('k') | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698