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

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: Created 4 years 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
« no previous file with comments | « README.md ('k') | pubspec.yaml » ('j') | pubspec.yaml » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
(...skipping 11 matching lines...) Expand all
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,
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
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).
204 /// 217 ///
218 /// This function is deprecated. Use [expectAsync0], [expectAsync1],
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
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 typedef T F0<T>();
247 typedef T F1<T, P0>(P0 p0);
248 typedef T F2<T, P0, P1>(P0 p0, P1 p1);
249 typedef T F3<T, P0, P1, P2>(P0 p0, P1 p1, P2 p2);
250 typedef T F4<T, P0, P1, P2, P3>(P0 p0, P1 p1, P2 p2, P3 p3);
251 typedef T F5<T, P0, P1, P2, P3, P4>(P0 p0, P1 p1, P2 p2, P3 p3, P4 p4);
252 typedef T F6<T, P0, P1, P2, P3, P4, P5>(
253 P0 p0, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
254
255 /// Indicate that [callback] is expected to be called [count] number of times
256 /// (by default 1).
257 ///
258 /// The test framework will wait for the callback to run the [count] times
259 /// before it considers the current test to be complete.
260 ///
261 /// [max] can be used to specify an upper bound on the number of calls; if this
262 /// is exceeded the test will fail. If [max] is `0` (the default), the callback
263 /// is expected to be called exactly [count] times. If [max] is `-1`, the
264 /// callback is allowed to be called any number of times greater than [count].
265 ///
266 /// Both [id] and [reason] are optional and provide extra information about the
267 /// callback when debugging. [id] should be the name of the callback, while
268 /// [reason] should be the reason the callback is expected to be called.
269 F0<dynamic/*=T*/ > expectAsync0/*<T>*/(dynamic/*=T*/ callback(),
270 {int count: 1, int max: 0, String id, String reason}) {
271 if (Invoker.current == null) {
272 throw new StateError("expectAsync() may only be called within a test.");
273 }
274
275 return new _ExpectedFunction/*<T>*/(callback, count, max,
276 id: id, reason: reason)
277 ._max0;
278 }
279
280 /// See [expectAsync0].
281 F1<dynamic/*=T*/, dynamic/*=P0*/ > expectAsync1/*<T, P0>*/(
282 dynamic/*=T*/ callback(dynamic/*=P0*/ p0),
283 {int count: 1,
284 int max: 0,
285 String id,
286 String reason}) {
287 if (Invoker.current == null) {
288 throw new StateError("expectAsync() may only be called within a test.");
289 }
290
291 return new _ExpectedFunction/*<T>*/(callback, count, max,
292 id: id, reason: reason)
293 ._max1;
294 }
295
296 /// See [expectAsync0].
297 F2<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/ > expectAsync2/*<T, P0, P1>*/(
298 dynamic/*=T*/ callback(dynamic/*=P0*/ p0, dynamic/*=P1*/ p1),
299 {int count: 1,
300 int max: 0,
301 String id,
302 String reason}) {
303 if (Invoker.current == null) {
304 throw new StateError("expectAsync() may only be called within a test.");
305 }
306
307 return new _ExpectedFunction/*<T>*/(callback, count, max,
308 id: id, reason: reason)
309 ._max2;
310 }
311
312 /// See [expectAsync0].
313 F3<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/ >
314 expectAsync3/*<T, P0, P1, P2>*/(
315 dynamic/*=T*/ callback(
316 dynamic/*=P0*/ p0, dynamic/*=P1*/ p1, dynamic/*=P2*/ p2),
317 {int count: 1,
318 int max: 0,
319 String id,
320 String reason}) {
321 if (Invoker.current == null) {
322 throw new StateError("expectAsync() may only be called within a test.");
323 }
324
325 return new _ExpectedFunction/*<T>*/(callback, count, max,
326 id: id, reason: reason)
327 ._max3;
328 }
329
330 /// See [expectAsync0].
331 F4<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/,
332 dynamic/*=P3*/ >
333 expectAsync4/*<T, P0, P1, P2, P3>*/(
334 dynamic/*=T*/ callback(dynamic/*=P0*/ p0, dynamic/*=P1*/ p1,
335 dynamic/*=P2*/ p2, dynamic/*=P3*/ p3),
336 {int count: 1,
337 int max: 0,
338 String id,
339 String reason}) {
340 if (Invoker.current == null) {
341 throw new StateError("expectAsync() may only be called within a test.");
342 }
343
344 return new _ExpectedFunction/*<T>*/(callback, count, max,
345 id: id, reason: reason)
346 ._max4;
347 }
348
349 /// See [expectAsync0].
350 F5<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/,
351 dynamic/*=P3*/, dynamic/*=P4*/ >
352 expectAsync5/*<T, P0, P1, P2, P3, P4>*/(
353 dynamic/*=T*/ callback(dynamic/*=P0*/ p0, dynamic/*=P1*/ p1,
354 dynamic/*=P2*/ p2, dynamic/*=P3*/ p3, dynamic/*=P4*/ p4),
355 {int count: 1,
356 int max: 0,
357 String id,
358 String reason}) {
359 if (Invoker.current == null) {
360 throw new StateError("expectAsync() may only be called within a test.");
361 }
362
363 return new _ExpectedFunction/*<T>*/(callback, count, max,
364 id: id, reason: reason)
365 ._max5;
366 }
367
368 /// See [expectAsync0].
369 F6<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/,
370 dynamic/*=P3*/, dynamic/*=P4*/, dynamic/*=P5*/ >
371 expectAsync6/*<T, P0, P1, P2, P3, P4, P5>*/(
372 dynamic/*=T*/ callback(
373 dynamic/*=P0*/ p0,
374 dynamic/*=P1*/ p1,
375 dynamic/*=P2*/ p2,
376 dynamic/*=P3*/ p3,
377 dynamic/*=P4*/ p4,
378 dynamic/*=P5*/ p5),
379 {int count: 1,
380 int max: 0,
381 String id,
382 String reason}) {
383 if (Invoker.current == null) {
384 throw new StateError("expectAsync() may only be called within a test.");
385 }
386
387 return new _ExpectedFunction/*<T>*/(callback, count, max,
388 id: id, reason: reason)
389 ._max6;
390 }
391
228 /// Indicate that [callback] is expected to be called until [isDone] returns 392 /// Indicate that [callback] is expected to be called until [isDone] returns
229 /// true. 393 /// true.
230 /// 394 ///
395 /// Deprecated. Use [expectAsyncUntil0], [expectAsyncUntil1],
396 /// [expectAsyncUntil2], [expectAsyncUntil3], [expectAsyncUntil4],
397 /// [expectAsyncUntil5], or [expectAsyncUntil6] instead.
398 ///
231 /// [isDone] is called after each time the function is run. Only when it returns 399 /// [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 400 /// true will the callback be considered complete. [callback] may take up to six
233 /// optional or required positional arguments; named arguments are not 401 /// optional or required positional arguments; named arguments are not
234 /// supported. 402 /// supported.
235 /// 403 ///
236 /// Both [id] and [reason] are optional and provide extra information about the 404 /// 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 405 /// 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. 406 /// [reason] should be the reason the callback is expected to be called.
407 @deprecated
239 Function expectAsyncUntil(Function callback, bool isDone(), 408 Function expectAsyncUntil(Function callback, bool isDone(),
240 {String id, String reason}) { 409 {String id, String reason}) {
241 if (Invoker.current == null) { 410 if (Invoker.current == null) {
242 throw new StateError( 411 throw new StateError(
243 "expectAsyncUntil() may only be called within a test."); 412 "expectAsyncUntil() may only be called within a test.");
244 } 413 }
245 414
246 return new _ExpectedFunction(callback, 0, -1, 415 return new _ExpectedFunction(callback, 0, -1,
247 id: id, reason: reason, isDone: isDone).func; 416 id: id, reason: reason, isDone: isDone)
417 .func;
248 } 418 }
419
420 /// Indicate that [callback] is expected to be called until [isDone] returns
421 /// true.
422 ///
423 /// [isDone] is called after each time the function is run. Only when it returns
424 /// true will the callback be considered complete.
425 ///
426 /// Both [id] and [reason] are optional and provide extra information about the
427 /// callback when debugging. [id] should be the name of the callback, while
428 /// [reason] should be the reason the callback is expected to be called.
429 F0<dynamic/*=T*/ > expectAsyncUntil0/*<T>*/(
430 dynamic/*=T*/ callback(), 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 ._max0;
440 }
441
442 /// See [expectAsyncUntil0].
443 F1<dynamic/*=T*/, dynamic/*=P0*/ > expectAsyncUntil1/*<T, P0>*/(
444 dynamic/*=T*/ callback(dynamic/*=P0*/ p0), bool isDone(),
445 {String id, String reason}) {
446 if (Invoker.current == null) {
447 throw new StateError(
448 "expectAsyncUntil() may only be called within a test.");
449 }
450
451 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
452 id: id, reason: reason, isDone: isDone)
453 ._max1;
454 }
455
456 /// See [expectAsyncUntil0].
457 F2<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/ >
458 expectAsyncUntil2/*<T, P0, P1>*/(
459 dynamic/*=T*/ callback(dynamic/*=P0*/ p0, dynamic/*=P1*/ p1),
460 bool isDone(),
461 {String id,
462 String reason}) {
463 if (Invoker.current == null) {
464 throw new StateError(
465 "expectAsyncUntil() may only be called within a test.");
466 }
467
468 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
469 id: id, reason: reason, isDone: isDone)
470 ._max2;
471 }
472
473 /// See [expectAsyncUntil0].
474 F3<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/ >
475 expectAsyncUntil3/*<T, P0, P1, P2>*/(
476 dynamic/*=T*/ callback(
477 dynamic/*=P0*/ p0, dynamic/*=P1*/ p1, dynamic/*=P2*/ p2),
478 bool isDone(),
479 {String id,
480 String reason}) {
481 if (Invoker.current == null) {
482 throw new StateError(
483 "expectAsyncUntil() may only be called within a test.");
484 }
485
486 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
487 id: id, reason: reason, isDone: isDone)
488 ._max3;
489 }
490
491 /// See [expectAsyncUntil0].
492 F4<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/,
493 dynamic/*=P3*/ >
494 expectAsyncUntil4/*<T, P0, P1, P2, P3>*/(
495 dynamic/*=T*/ callback(dynamic/*=P0*/ p0, dynamic/*=P1*/ p1,
496 dynamic/*=P2*/ p2, dynamic/*=P3*/ p3),
497 bool isDone(),
498 {String id,
499 String reason}) {
500 if (Invoker.current == null) {
501 throw new StateError(
502 "expectAsyncUntil() may only be called within a test.");
503 }
504
505 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
506 id: id, reason: reason, isDone: isDone)
507 ._max4;
508 }
509
510 /// See [expectAsyncUntil0].
511 F5<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/,
512 dynamic/*=P3*/, dynamic/*=P4*/ >
513 expectAsyncUntil5/*<T, P0, P1, P2, P3, P4>*/(
514 dynamic/*=T*/ callback(dynamic/*=P0*/ p0, dynamic/*=P1*/ p1,
515 dynamic/*=P2*/ p2, dynamic/*=P3*/ p3, dynamic/*=P4*/ p4),
516 bool isDone(),
517 {String id,
518 String reason}) {
519 if (Invoker.current == null) {
520 throw new StateError(
521 "expectAsyncUntil() may only be called within a test.");
522 }
523
524 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
525 id: id, reason: reason, isDone: isDone)
526 ._max5;
527 }
528
529 /// See [expectAsyncUntil0].
530 F6<dynamic/*=T*/, dynamic/*=P0*/, dynamic/*=P1*/, dynamic/*=P2*/,
531 dynamic/*=P3*/, dynamic/*=P4*/, dynamic/*=P5*/ >
532 expectAsyncUntil6/*<T, P0, P1, P2, P3, P4, P5>*/(
533 dynamic/*=T*/ callback(
534 dynamic/*=P0*/ p0,
535 dynamic/*=P1*/ p1,
536 dynamic/*=P2*/ p2,
537 dynamic/*=P3*/ p3,
538 dynamic/*=P4*/ p4,
539 dynamic/*=P5*/ p5),
540 bool isDone(),
541 {String id,
542 String reason}) {
543 if (Invoker.current == null) {
544 throw new StateError(
545 "expectAsyncUntil() may only be called within a test.");
546 }
547
548 return new _ExpectedFunction/*<T>*/(callback, 0, -1,
549 id: id, reason: reason, isDone: isDone)
550 ._max6;
551 }
OLDNEW
« no previous file with comments | « README.md ('k') | pubspec.yaml » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698