| 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 // TODO(nweiz): Add support for calling [schedule] while the schedule is already | 5 // TODO(nweiz): Add support for calling [schedule] while the schedule is already |
| 6 // running. | 6 // running. |
| 7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. | 7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. |
| 8 /// A package for writing readable tests of asynchronous behavior. | 8 /// A package for writing readable tests of asynchronous behavior. |
| 9 /// | 9 /// |
| 10 /// This package works by building up a queue of asynchronous tasks called a | 10 /// This package works by building up a queue of asynchronous tasks called a |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 unittest.tearDown(() { | 311 unittest.tearDown(() { |
| 312 _currentSchedule = null; | 312 _currentSchedule = null; |
| 313 }); | 313 }); |
| 314 } | 314 } |
| 315 | 315 |
| 316 /// Ensures that the global configuration for `scheduled_test` has been | 316 /// Ensures that the global configuration for `scheduled_test` has been |
| 317 /// initialized. | 317 /// initialized. |
| 318 void _ensureInitialized() { | 318 void _ensureInitialized() { |
| 319 unittest.ensureInitialized(); | 319 unittest.ensureInitialized(); |
| 320 unittest.wrapAsync = (f, [id = '']) { | 320 unittest.wrapAsync = (f, [description]) { |
| 321 if (currentSchedule == null) { | 321 if (currentSchedule == null) { |
| 322 throw new StateError("Unexpected call to wrapAsync with no current " | 322 throw new StateError("Unexpected call to wrapAsync with no current " |
| 323 "schedule."); | 323 "schedule."); |
| 324 } | 324 } |
| 325 | 325 |
| 326 return currentSchedule.wrapAsync(f); | 326 return currentSchedule.wrapAsync(f, description); |
| 327 }; | 327 }; |
| 328 } | 328 } |
| 329 | 329 |
| 330 /// Like [wrapAsync], this ensures that the current task queue waits for | 330 /// Like [wrapAsync], this ensures that the current task queue waits for |
| 331 /// out-of-band asynchronous code, and that errors raised in that code are | 331 /// out-of-band asynchronous code, and that errors raised in that code are |
| 332 /// handled correctly. However, [wrapFuture] wraps a [Future] chain rather than | 332 /// handled correctly. However, [wrapFuture] wraps a [Future] chain rather than |
| 333 /// a single callback. | 333 /// a single callback. |
| 334 /// | 334 /// |
| 335 /// The returned [Future] completes to the same value or error as [future]. | 335 /// The returned [Future] completes to the same value or error as [future]. |
| 336 Future wrapFuture(Future future) { | 336 Future wrapFuture(Future future) { |
| 337 if (currentSchedule == null) { | 337 if (currentSchedule == null) { |
| 338 throw new StateError("Unexpected call to wrapFuture with no current " | 338 throw new StateError("Unexpected call to wrapFuture with no current " |
| 339 "schedule."); | 339 "schedule."); |
| 340 } | 340 } |
| 341 | 341 |
| 342 return currentSchedule.wrapFuture(future); | 342 return currentSchedule.wrapFuture(future); |
| 343 } | 343 } |
| OLD | NEW |