Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 future_test; | 5 library future_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 | 9 |
| 10 testImmediate() { | 10 testImmediate() { |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 | 511 |
| 512 var port = new ReceivePort(); | 512 var port = new ReceivePort(); |
| 513 future.catchError((AsyncError e) { | 513 future.catchError((AsyncError e) { |
| 514 Expect.identical(error, e); | 514 Expect.identical(error, e); |
| 515 port.close(); | 515 port.close(); |
| 516 }); | 516 }); |
| 517 | 517 |
| 518 completer.completeError(error); | 518 completer.completeError(error); |
| 519 } | 519 } |
| 520 | 520 |
| 521 testChainedFutureValue() { | |
| 522 final completer = new Completer(); | |
| 523 final future = completer.future; | |
| 524 var port = new ReceivePort(); | |
| 525 | |
| 526 future.then((v) => new Future.immediate(v * 2)) | |
| 527 .then((v) { | |
| 528 Expect.equals(42, v); | |
|
Mads Ager (google)
2013/01/21 12:51:10
I would expect this to be indented one more space
Lasse Reichstein Nielsen
2013/01/21 13:09:39
unindented '}'.
| |
| 529 port.close(); | |
| 530 }); | |
| 531 completer.complete(21); | |
| 532 } | |
| 533 | |
| 534 testChainedFutureValueDelay() { | |
| 535 final completer = new Completer(); | |
| 536 final future = completer.future; | |
| 537 var port = new ReceivePort(); | |
| 538 | |
| 539 future.then((v) => new Future.delayed(10, () => v * 2)) | |
| 540 .then((v) { | |
| 541 Expect.equals(42, v); | |
| 542 port.close(); | |
| 543 }); | |
| 544 completer.complete(21); | |
| 545 } | |
| 546 | |
| 547 testChainedFutureError() { | |
| 548 final completer = new Completer(); | |
| 549 final future = completer.future; | |
| 550 var port = new ReceivePort(); | |
| 551 | |
| 552 future.then((v) => new Future.immediateError("Fehler")) | |
| 553 .then((v) { Expect.fail("unreachable!"); }, onError: (e) { | |
| 554 Expect.equals("Fehler", e.error); | |
| 555 port.close(); | |
| 556 }); | |
| 557 completer.complete(21); | |
| 558 } | |
| 559 | |
| 521 main() { | 560 main() { |
| 522 testImmediate(); | 561 testImmediate(); |
| 523 testNeverComplete(); | 562 testNeverComplete(); |
| 524 | 563 |
| 525 testComplete(); | 564 testComplete(); |
| 526 testCompleteWithSuccessHandlerBeforeComplete(); | 565 testCompleteWithSuccessHandlerBeforeComplete(); |
| 527 testCompleteWithSuccessHandlerAfterComplete(); | 566 testCompleteWithSuccessHandlerAfterComplete(); |
| 528 testCompleteManySuccessHandlers(); | 567 testCompleteManySuccessHandlers(); |
| 529 testCompleteWithAsyncError(); | 568 testCompleteWithAsyncError(); |
| 530 | 569 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 547 | 586 |
| 548 testFutureWhenValueFutureValue(); | 587 testFutureWhenValueFutureValue(); |
| 549 testFutureWhenErrorFutureValue(); | 588 testFutureWhenErrorFutureValue(); |
| 550 testFutureWhenValueFutureError(); | 589 testFutureWhenValueFutureError(); |
| 551 testFutureWhenErrorFutureError(); | 590 testFutureWhenErrorFutureError(); |
| 552 | 591 |
| 553 testFutureThenThrowsAsync(); | 592 testFutureThenThrowsAsync(); |
| 554 testFutureCatchThrowsAsync(); | 593 testFutureCatchThrowsAsync(); |
| 555 testFutureWhenThrowsAsync(); | 594 testFutureWhenThrowsAsync(); |
| 556 testFutureCatchRethrowsAsync(); | 595 testFutureCatchRethrowsAsync(); |
| 596 | |
| 597 testChainedFutureValue(); | |
| 598 testChainedFutureValueDelay(); | |
| 599 testChainedFutureError(); | |
| 557 } | 600 } |
| 558 | 601 |
| OLD | NEW |