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

Side by Side Diff: lib/src/frontend/expect_async.dart

Issue 2515303002: Add expectAsyncX and expectAsyncUntilX methods, and deprecate the old methods. (Closed)
Patch Set: Make '_Func' typedefs public. Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../backend/invoker.dart'; 7 import '../backend/invoker.dart';
8 import 'expect.dart'; 8 import 'expect.dart';
9 9
10 /// An object used to detect unpassed arguments. 10 /// An object used to detect unpassed arguments.
11 const _PLACEHOLDER = const Object(); 11 const _PLACEHOLDER = const Object();
12 12
13 // Functions used to check how many arguments a callback takes. 13 // Functions used to check how many arguments a callback takes.
14 typedef _Func0(); 14 typedef T Func0<T>();
15 typedef _Func1(a); 15 typedef T Func1<T, A>(A a);
16 typedef _Func2(a, b); 16 typedef T Func2<T, A, B>(A a, B b);
17 typedef _Func3(a, b, c); 17 typedef T Func3<T, A, B, C>(A a, B b, C c);
18 typedef _Func4(a, b, c, d); 18 typedef T Func4<T, A, B, C, D>(A a, B b, C c, D d);
19 typedef _Func5(a, b, c, d, e); 19 typedef T Func5<T, A, B, C, D, E>(A a, B b, C c, D d, E e);
20 typedef _Func6(a, b, c, d, e, f); 20 typedef T Func6<T, A, B, C, D, E, F>(A a, B b, C c, D d, E e, F f);
21 21
22 typedef bool _IsDoneCallback(); 22 typedef bool _IsDoneCallback();
23 23
24 /// A wrapper for a function that ensures that it's called the appropriate 24 /// A wrapper for a function that ensures that it's called the appropriate
25 /// number of times. 25 /// number of times.
26 /// 26 ///
27 /// The containing test won't be considered to have completed successfully until 27 /// The containing test won't be considered to have completed successfully until
28 /// this function has been called the appropriate number of times. 28 /// this function has been called the appropriate number of times.
29 /// 29 ///
30 /// The wrapper function is accessible via [func]. It supports up to six 30 /// The wrapper function is accessible via [func]. It supports up to six
31 /// optional and/or required positional arguments, but no named arguments. 31 /// optional and/or required positional arguments, but no named arguments.
32 class _ExpectedFunction { 32 class _ExpectedFunction<T> {
33 /// The wrapped callback. 33 /// The wrapped callback.
34 final Function _callback; 34 final Function _callback;
35 35
36 /// The minimum number of calls that are expected to be made to the function. 36 /// The minimum number of calls that are expected to be made to the function.
37 /// 37 ///
38 /// If fewer calls than this are made, the test will fail. 38 /// If fewer calls than this are made, the test will fail.
39 final int _minExpectedCalls; 39 final int _minExpectedCalls;
40 40
41 /// The maximum number of calls that are expected to be made to the function. 41 /// The maximum number of calls that are expected to be made to the function.
42 /// 42 ///
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 /// Wraps [callback] in a function that asserts that it's called at least 76 /// Wraps [callback] in a function that asserts that it's called at least
77 /// [minExpected] times and no more than [maxExpected] times. 77 /// [minExpected] times and no more than [maxExpected] times.
78 /// 78 ///
79 /// If passed, [id] is used as a descriptive name fo the function and [reason] 79 /// If passed, [id] is used as a descriptive name fo the function and [reason]
80 /// as a reason it's expected to be called. If [isDone] is passed, the test 80 /// as a reason it's expected to be called. If [isDone] is passed, the test
81 /// won't be allowed to complete until it returns `true`. 81 /// won't be allowed to complete until it returns `true`.
82 _ExpectedFunction(Function callback, int minExpected, int maxExpected, 82 _ExpectedFunction(Function callback, int minExpected, int maxExpected,
83 {String id, String reason, bool isDone()}) 83 {String id, String reason, bool isDone()})
84 : this._callback = callback, 84 : this._callback = callback,
85 _minExpectedCalls = minExpected, 85 _minExpectedCalls = minExpected,
86 _maxExpectedCalls = (maxExpected == 0 && minExpected > 0) 86 _maxExpectedCalls =
87 ? minExpected 87 (maxExpected == 0 && minExpected > 0) ? minExpected : maxExpected,
nweiz 2016/11/21 22:08:02 Nit: Please don't include unrelated whitespace dif
floitsch 2016/11/22 14:14:27 I tried, but writing multiline function signatures
88 : maxExpected,
89 this._isDone = isDone, 88 this._isDone = isDone,
90 this._reason = reason == null ? '' : '\n$reason', 89 this._reason = reason == null ? '' : '\n$reason',
91 this._zone = Zone.current, 90 this._zone = Zone.current,
92 this._id = _makeCallbackId(id, callback) { 91 this._id = _makeCallbackId(id, callback) {
93 if (_invoker == null) { 92 if (_invoker == null) {
94 throw new StateError("[expectAsync] was called outside of a test."); 93 throw new StateError("[expectAsync] was called outside of a test.");
95 } else if (maxExpected > 0 && minExpected > maxExpected) { 94 } else if (maxExpected > 0 && minExpected > maxExpected) {
96 throw new ArgumentError("max ($maxExpected) may not be less than count " 95 throw new ArgumentError("max ($maxExpected) may not be less than count "
97 "($minExpected)."); 96 "($minExpected).");
98 } 97 }
(...skipping 22 matching lines...) Expand all
121 120
122 start += prefix.length; 121 start += prefix.length;
123 var end = toString.indexOf("'", start); 122 var end = toString.indexOf("'", start);
124 if (end == -1) return ''; 123 if (end == -1) return '';
125 return "${toString.substring(start, end)} "; 124 return "${toString.substring(start, end)} ";
126 } 125 }
127 126
128 /// Returns a function that has the same number of positional arguments as the 127 /// Returns a function that has the same number of positional arguments as the
129 /// wrapped function (up to a total of 6). 128 /// wrapped function (up to a total of 6).
130 Function get func { 129 Function get func {
131 if (_callback is _Func6) return _max6; 130 if (_callback is Func6) return _max6;
132 if (_callback is _Func5) return _max5; 131 if (_callback is Func5) return _max5;
133 if (_callback is _Func4) return _max4; 132 if (_callback is Func4) return _max4;
134 if (_callback is _Func3) return _max3; 133 if (_callback is Func3) return _max3;
135 if (_callback is _Func2) return _max2; 134 if (_callback is Func2) return _max2;
136 if (_callback is _Func1) return _max1; 135 if (_callback is Func1) return _max1;
137 if (_callback is _Func0) return _max0; 136 if (_callback is Func0) return _max0;
138 137
139 _invoker.removeOutstandingCallback(); 138 _invoker.removeOutstandingCallback();
140 throw new ArgumentError( 139 throw new ArgumentError(
141 'The wrapped function has more than 6 required arguments'); 140 'The wrapped function has more than 6 required arguments');
142 } 141 }
143 142
144 // This indirection is critical. It ensures the returned function has an 143 // This indirection is critical. It ensures the returned function has an
145 // argument count of zero. 144 // argument count of zero.
146 _max0() => _max6(); 145 T _max0() => _max6();
nweiz 2016/11/21 22:08:02 Since these are being accessed outside the class n
floitsch 2016/11/22 14:14:27 Done.
147 146
148 _max1([a0 = _PLACEHOLDER]) => _max6(a0); 147 T _max1([a0 = _PLACEHOLDER]) => _max6(a0);
149 148
150 _max2([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER]) => _max6(a0, a1); 149 T _max2([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER]) => _max6(a0, a1);
151 150
152 _max3([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER]) => 151 T _max3([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER]) =>
153 _max6(a0, a1, a2); 152 _max6(a0, a1, a2);
154 153
155 _max4([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER, 154 T _max4(
156 a3 = _PLACEHOLDER]) => _max6(a0, a1, a2, a3); 155 [a0 = _PLACEHOLDER,
156 a1 = _PLACEHOLDER,
157 a2 = _PLACEHOLDER,
158 a3 = _PLACEHOLDER]) =>
159 _max6(a0, a1, a2, a3);
157 160
158 _max5([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER, 161 T _max5(
159 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER]) => _max6(a0, a1, a2, a3, a4); 162 [a0 = _PLACEHOLDER,
163 a1 = _PLACEHOLDER,
164 a2 = _PLACEHOLDER,
165 a3 = _PLACEHOLDER,
166 a4 = _PLACEHOLDER]) =>
167 _max6(a0, a1, a2, a3, a4);
160 168
161 _max6([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER, 169 T _max6(
162 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER, a5 = _PLACEHOLDER]) => 170 [a0 = _PLACEHOLDER,
171 a1 = _PLACEHOLDER,
172 a2 = _PLACEHOLDER,
173 a3 = _PLACEHOLDER,
174 a4 = _PLACEHOLDER,
175 a5 = _PLACEHOLDER]) =>
163 _run([a0, a1, a2, a3, a4, a5].where((a) => a != _PLACEHOLDER)); 176 _run([a0, a1, a2, a3, a4, a5].where((a) => a != _PLACEHOLDER));
164 177
165 /// Runs the wrapped function with [args] and returns its return value. 178 /// Runs the wrapped function with [args] and returns its return value.
166 _run(Iterable args) { 179 T _run(Iterable args) {
167 // Note that in the old test, this returned `null` if it encountered an 180 // Note that in the old test, this returned `null` if it encountered an
168 // error, where now it just re-throws that error because Zone machinery will 181 // error, where now it just re-throws that error because Zone machinery will
169 // pass it to the invoker anyway. 182 // pass it to the invoker anyway.
170 try { 183 try {
171 _actualCalls++; 184 _actualCalls++;
172 if (_invoker.liveTest.state.shouldBeDone) { 185 if (_invoker.liveTest.state.shouldBeDone) {
173 throw 'Callback ${_id}called ($_actualCalls) after test case ' 186 throw 'Callback ${_id}called ($_actualCalls) after test case '
174 '${_invoker.liveTest.test.name} had already completed.$_reason'; 187 '${_invoker.liveTest.test.name} had already completed.$_reason';
175 } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) { 188 } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) {
176 throw new TestFailure('Callback ${_id}called more times than expected ' 189 throw new TestFailure('Callback ${_id}called more times than expected '
177 '($_maxExpectedCalls).$_reason'); 190 '($_maxExpectedCalls).$_reason');
178 } 191 }
179 192
180 return Function.apply(_callback, args.toList()); 193 return Function.apply(_callback, args.toList()) as T;
181 } catch (error, stackTrace) { 194 } catch (error, stackTrace) {
182 _zone.handleUncaughtError(error, stackTrace); 195 _zone.handleUncaughtError(error, stackTrace);
183 return null; 196 return null;
184 } finally { 197 } finally {
185 _afterRun(); 198 _afterRun();
186 } 199 }
187 } 200 }
188 201
189 /// After each time the function is run, check to see if it's complete. 202 /// After each time the function is run, check to see if it's complete.
190 void _afterRun() { 203 void _afterRun() {
191 if (_complete) return; 204 if (_complete) return;
192 if (_minExpectedCalls > 0 && _actualCalls < _minExpectedCalls) return; 205 if (_minExpectedCalls > 0 && _actualCalls < _minExpectedCalls) return;
193 if (_isDone != null && !_isDone()) return; 206 if (_isDone != null && !_isDone()) return;
194 207
195 // Mark this callback as complete and remove it from the test case's 208 // Mark this callback as complete and remove it from the test case's
196 // oustanding callback count; if that hits zero the test is done. 209 // oustanding callback count; if that hits zero the test is done.
197 _complete = true; 210 _complete = true;
198 _invoker.removeOutstandingCallback(); 211 _invoker.removeOutstandingCallback();
199 } 212 }
200 } 213 }
201 214
202 /// Indicate that [callback] is expected to be called [count] number of times 215 /// Indicate that [callback] is expected to be called [count] number of times
203 /// (by default 1). 216 /// (by default 1).
nweiz 2016/11/21 22:08:02 Remove the old documentation.
floitsch 2016/11/22 14:14:27 Done.
204 /// 217 ///
218 /// This function is deprecated. Use [expectAsync0], [expectAsync1],
nweiz 2016/11/21 22:08:02 "is deprecated because it doesn't work well with s
floitsch 2016/11/22 14:14:27 Done.
219 /// [expectAsync2], [expectAsync3], [expectAsync4], [expectAsync5], or
220 /// [expectAsync6] instead.
221 ///
205 /// The test framework will wait for the callback to run the [count] times 222 /// The test framework will wait for the callback to run the [count] times
206 /// before it considers the current test to be complete. [callback] may take up 223 /// before it considers the current test to be complete. [callback] may take up
207 /// to six optional or required positional arguments; named arguments are not 224 /// to six optional or required positional arguments; named arguments are not
208 /// supported. 225 /// supported.
209 /// 226 ///
210 /// [max] can be used to specify an upper bound on the number of calls; if this 227 /// [max] can be used to specify an upper bound on the number of calls; if this
211 /// is exceeded the test will fail. If [max] is `0` (the default), the callback 228 /// is exceeded the test will fail. If [max] is `0` (the default), the callback
212 /// is expected to be called exactly [count] times. If [max] is `-1`, the 229 /// is expected to be called exactly [count] times. If [max] is `-1`, the
213 /// callback is allowed to be called any number of times greater than [count]. 230 /// callback is allowed to be called any number of times greater than [count].
214 /// 231 ///
215 /// Both [id] and [reason] are optional and provide extra information about the 232 /// Both [id] and [reason] are optional and provide extra information about the
216 /// callback when debugging. [id] should be the name of the callback, while 233 /// callback when debugging. [id] should be the name of the callback, while
217 /// [reason] should be the reason the callback is expected to be called. 234 /// [reason] should be the reason the callback is expected to be called.
235 @deprecated
nweiz 2016/11/21 22:08:02 Use @Deprecated and mention that it will be remove
floitsch 2016/11/22 14:14:27 Done.
218 Function expectAsync(Function callback, 236 Function expectAsync(Function callback,
219 {int count: 1, int max: 0, String id, String reason}) { 237 {int count: 1, int max: 0, String id, String reason}) {
220 if (Invoker.current == null) { 238 if (Invoker.current == null) {
221 throw new StateError("expectAsync() may only be called within a test."); 239 throw new StateError("expectAsync() may only be called within a test.");
222 } 240 }
223 241
224 return new _ExpectedFunction(callback, count, max, id: id, reason: reason) 242 return new _ExpectedFunction(callback, count, max, id: id, reason: reason)
225 .func; 243 .func;
226 } 244 }
227 245
246 /// Indicate that [callback] is expected to be called [count] number of times
247 /// (by default 1).
248 ///
249 /// The test framework will wait for the callback to run the [count] times
250 /// before it considers the current test to be complete.
251 ///
252 /// [max] can be used to specify an upper bound on the number of calls; if this
253 /// is exceeded the test will fail. If [max] is `0` (the default), the callback
254 /// is expected to be called exactly [count] times. If [max] is `-1`, the
255 /// callback is allowed to be called any number of times greater than [count].
256 ///
257 /// Both [id] and [reason] are optional and provide extra information about the
258 /// callback when debugging. [id] should be the name of the callback, while
259 /// [reason] should be the reason the callback is expected to be called.
nweiz 2016/11/21 22:08:03 Add a paragraph describing the difference between
floitsch 2016/11/22 14:14:27 Done.
260 Func0<dynamic/*=T*/ > expectAsync0/*<T>*/(dynamic/*=T*/ callback(),
nweiz 2016/11/21 22:08:02 Nit: "<dynamic/*=T*/>"
floitsch 2016/11/22 14:14:27 I don't understand. If it's the spacing: I used th
261 {int count: 1, int max: 0, String id, String reason}) {
262 if (Invoker.current == null) {
263 throw new StateError("expectAsync() may only be called within a test.");
nweiz 2016/11/21 22:08:02 "expectAsync0()"
floitsch 2016/11/22 14:14:27 Done.
264 }
265
266 return new _ExpectedFunction/*<T>*/(callback, count, max,
267 id: id, reason: reason)
268 ._max0;
269 }
270
271 /// See [expectAsync0].
nweiz 2016/11/21 22:08:02 I'd prefer to copy the docs from [expectAsync0] ra
floitsch 2016/11/22 14:14:27 Done.
272 Func1<dynamic/*=T*/, dynamic/*=A*/ > expectAsync1/*<T, A>*/(
273 dynamic/*=T*/ callback(dynamic/*=A*/ a),
274 {int count: 1,
275 int max: 0,
276 String id,
277 String reason}) {
278 if (Invoker.current == null) {
279 throw new StateError("expectAsync() may only be called within a test.");
280 }
281
282 return new _ExpectedFunction/*<T>*/(callback, count, max,
283 id: id, reason: reason)
284 ._max1;
285 }
286
287 /// See [expectAsync0].
288 Func2<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/ > expectAsync2/*<T, A, B>*/(
289 dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b),
290 {int count: 1,
291 int max: 0,
292 String id,
293 String reason}) {
294 if (Invoker.current == null) {
295 throw new StateError("expectAsync() may only be called within a test.");
296 }
297
298 return new _ExpectedFunction/*<T>*/(callback, count, max,
299 id: id, reason: reason)
300 ._max2;
301 }
302
303 /// See [expectAsync0].
304 Func3<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/ >
305 expectAsync3/*<T, A, B, C>*/(
306 dynamic/*=T*/ callback(
307 dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c),
308 {int count: 1,
309 int max: 0,
310 String id,
311 String reason}) {
312 if (Invoker.current == null) {
313 throw new StateError("expectAsync() may only be called within a test.");
314 }
315
316 return new _ExpectedFunction/*<T>*/(callback, count, max,
317 id: id, reason: reason)
318 ._max3;
319 }
320
321 /// See [expectAsync0].
322 Func4<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/,
323 dynamic/*=D*/ >
324 expectAsync4/*<T, A, B, C, D>*/(
325 dynamic/*=T*/ callback(
326 dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c, dynamic/*=D*/ d),
327 {int count: 1,
328 int max: 0,
329 String id,
330 String reason}) {
331 if (Invoker.current == null) {
332 throw new StateError("expectAsync() may only be called within a test.");
333 }
334
335 return new _ExpectedFunction/*<T>*/(callback, count, max,
336 id: id, reason: reason)
337 ._max4;
338 }
339
340 /// See [expectAsync0].
341 Func5<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/,
342 dynamic/*=D*/, dynamic/*=E*/ >
343 expectAsync5/*<T, A, B, C, D, E>*/(
344 dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b,
345 dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e),
346 {int count: 1,
347 int max: 0,
348 String id,
349 String reason}) {
350 if (Invoker.current == null) {
351 throw new StateError("expectAsync() may only be called within a test.");
352 }
353
354 return new _ExpectedFunction/*<T>*/(callback, count, max,
355 id: id, reason: reason)
356 ._max5;
357 }
358
359 /// See [expectAsync0].
360 Func6<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/,
361 dynamic/*=D*/, dynamic/*=E*/, dynamic/*=F*/ >
362 expectAsync6/*<T, A, B, C, D, E, F>*/(
363 dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b,
364 dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e, dynamic/*=F*/ f),
365 {int count: 1,
366 int max: 0,
367 String id,
368 String reason}) {
369 if (Invoker.current == null) {
370 throw new StateError("expectAsync() may only be called within a test.");
371 }
372
373 return new _ExpectedFunction/*<T>*/(callback, count, max,
374 id: id, reason: reason)
375 ._max6;
376 }
377
228 /// Indicate that [callback] is expected to be called until [isDone] returns 378 /// Indicate that [callback] is expected to be called until [isDone] returns
229 /// true. 379 /// true.
230 /// 380 ///
381 /// Deprecated. Use [expectAsyncUntil0], [expectAsyncUntil1],
382 /// [expectAsyncUntil2], [expectAsyncUntil3], [expectAsyncUntil4],
383 /// [expectAsyncUntil5], or [expectAsyncUntil6] instead.
384 ///
231 /// [isDone] is called after each time the function is run. Only when it returns 385 /// [isDone] is called after each time the function is run. Only when it returns
232 /// true will the callback be considered complete. [callback] may take up to six 386 /// true will the callback be considered complete. [callback] may take up to six
233 /// optional or required positional arguments; named arguments are not 387 /// optional or required positional arguments; named arguments are not
234 /// supported. 388 /// supported.
235 /// 389 ///
236 /// Both [id] and [reason] are optional and provide extra information about the 390 /// Both [id] and [reason] are optional and provide extra information about the
237 /// callback when debugging. [id] should be the name of the callback, while 391 /// callback when debugging. [id] should be the name of the callback, while
238 /// [reason] should be the reason the callback is expected to be called. 392 /// [reason] should be the reason the callback is expected to be called.
393 @deprecated
239 Function expectAsyncUntil(Function callback, bool isDone(), 394 Function expectAsyncUntil(Function callback, bool isDone(),
240 {String id, String reason}) { 395 {String id, String reason}) {
241 if (Invoker.current == null) { 396 if (Invoker.current == null) {
242 throw new StateError( 397 throw new StateError(
243 "expectAsyncUntil() may only be called within a test."); 398 "expectAsyncUntil() may only be called within a test.");
244 } 399 }
245 400
246 return new _ExpectedFunction(callback, 0, -1, 401 return new _ExpectedFunction(callback, 0, -1,
247 id: id, reason: reason, isDone: isDone).func; 402 id: id, reason: reason, isDone: isDone)
403 .func;
248 } 404 }
405
406 /// Indicate that [callback] is expected to be called until [isDone] returns
407 /// true.
408 ///
409 /// [isDone] is called after each time the function is run. Only when it returns
410 /// true will the callback be considered complete.
411 ///
412 /// Both [id] and [reason] are optional and provide extra information about the
413 /// callback when debugging. [id] should be the name of the callback, while
414 /// [reason] should be the reason the callback is expected to be called.
415 Func0<dynamic/*=T*/ > expectAsyncUntil0/*<T>*/(
416 dynamic/*=T*/ callback(), bool isDone(),
417 {String id, String reason}) {
418 if (Invoker.current == null) {
419 throw new StateError(
420 "expectAsyncUntil() may only be called within a test.");
421 }
422
423 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
424 id: id, reason: reason, isDone: isDone)
425 ._max0;
426 }
427
428 /// See [expectAsyncUntil0].
429 Func1<dynamic/*=T*/, dynamic/*=A*/ > expectAsyncUntil1/*<T, A>*/(
430 dynamic/*=T*/ callback(dynamic/*=A*/ a), bool isDone(),
431 {String id, String reason}) {
432 if (Invoker.current == null) {
433 throw new StateError(
434 "expectAsyncUntil() may only be called within a test.");
435 }
436
437 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
438 id: id, reason: reason, isDone: isDone)
439 ._max1;
440 }
441
442 /// See [expectAsyncUntil0].
443 Func2<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/ >
444 expectAsyncUntil2/*<T, A, B>*/(
445 dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b), bool isDone(),
446 {String id, String reason}) {
447 if (Invoker.current == null) {
448 throw new StateError(
449 "expectAsyncUntil() may only be called within a test.");
450 }
451
452 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
453 id: id, reason: reason, isDone: isDone)
454 ._max2;
455 }
456
457 /// See [expectAsyncUntil0].
458 Func3<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/ >
459 expectAsyncUntil3/*<T, A, B, C>*/(
460 dynamic/*=T*/ callback(
461 dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c),
462 bool isDone(),
463 {String id,
464 String reason}) {
465 if (Invoker.current == null) {
466 throw new StateError(
467 "expectAsyncUntil() may only be called within a test.");
468 }
469
470 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
471 id: id, reason: reason, isDone: isDone)
472 ._max3;
473 }
474
475 /// See [expectAsyncUntil0].
476 Func4<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/,
477 dynamic/*=D*/ >
478 expectAsyncUntil4/*<T, A, B, C, D>*/(
479 dynamic/*=T*/ callback(
480 dynamic/*=A*/ a, dynamic/*=B*/ b, dynamic/*=C*/ c, dynamic/*=D*/ d),
481 bool isDone(),
482 {String id,
483 String reason}) {
484 if (Invoker.current == null) {
485 throw new StateError(
486 "expectAsyncUntil() may only be called within a test.");
487 }
488
489 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
490 id: id, reason: reason, isDone: isDone)
491 ._max4;
492 }
493
494 /// See [expectAsyncUntil0].
495 Func5<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/,
496 dynamic/*=D*/, dynamic/*=E*/ >
497 expectAsyncUntil5/*<T, A, B, C, D, E>*/(
498 dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b,
499 dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e),
500 bool isDone(),
501 {String id,
502 String reason}) {
503 if (Invoker.current == null) {
504 throw new StateError(
505 "expectAsyncUntil() may only be called within a test.");
506 }
507
508 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
509 id: id, reason: reason, isDone: isDone)
510 ._max5;
511 }
512
513 /// See [expectAsyncUntil0].
514 Func6<dynamic/*=T*/, dynamic/*=A*/, dynamic/*=B*/, dynamic/*=C*/,
515 dynamic/*=D*/, dynamic/*=E*/, dynamic/*=F*/ >
516 expectAsyncUntil6/*<T, A, B, C, D, E, F>*/(
517 dynamic/*=T*/ callback(dynamic/*=A*/ a, dynamic/*=B*/ b,
518 dynamic/*=C*/ c, dynamic/*=D*/ d, dynamic/*=E*/ e, dynamic/*=F*/ f),
519 bool isDone(),
520 {String id,
521 String reason}) {
522 if (Invoker.current == null) {
523 throw new StateError(
524 "expectAsyncUntil() may only be called within a test.");
525 }
526
527 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
528 id: id, reason: reason, isDone: isDone)
529 ._max6;
530 }
OLDNEW
« CHANGELOG.md ('K') | « README.md ('k') | test/backend/declarer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698