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

Side by Side Diff: tests/lib/async/future_test.dart

Issue 23926011: Rewrite Futures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix bad asserts. Created 7 years, 3 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 | « sdk/lib/async/zone.dart ('k') | tests/lib/async/future_value_chain2_test.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 // 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 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 asyncStart(); 610 asyncStart();
611 611
612 future.then((v) => new Future.error("Fehler")) 612 future.then((v) => new Future.error("Fehler"))
613 .then((v) { Expect.fail("unreachable!"); }, onError: (error) { 613 .then((v) { Expect.fail("unreachable!"); }, onError: (error) {
614 Expect.equals("Fehler", error); 614 Expect.equals("Fehler", error);
615 asyncEnd(); 615 asyncEnd();
616 }); 616 });
617 completer.complete(21); 617 completer.complete(21);
618 } 618 }
619 619
620 void testChainedFutureCycle() {
621 asyncStart();
622 var completer = new Completer();
623 var future, future2;
624 future = completer.future.then((_) => future2);
625 future2 = completer.future.then((_) => future);
626 completer.complete(42);
627 int ctr = 2;
628 void receiveError(e) {
629 Expect.isTrue(e is StateError);
630 if (--ctr == 0) asyncEnd();
631 }
632 future.catchError(receiveError);
633 future.catchError(receiveError);
634 }
635
636 main() { 620 main() {
637 testValue(); 621 testValue();
638 testSync(); 622 testSync();
639 testNeverComplete(); 623 testNeverComplete();
640 624
641 testComplete(); 625 testComplete();
642 testCompleteWithSuccessHandlerBeforeComplete(); 626 testCompleteWithSuccessHandlerBeforeComplete();
643 testCompleteWithSuccessHandlerAfterComplete(); 627 testCompleteWithSuccessHandlerAfterComplete();
644 testCompleteManySuccessHandlers(); 628 testCompleteManySuccessHandlers();
645 testCompleteWithError(); 629 testCompleteWithError();
(...skipping 21 matching lines...) Expand all
667 testFutureWhenErrorFutureError(); 651 testFutureWhenErrorFutureError();
668 652
669 testFutureThenThrowsAsync(); 653 testFutureThenThrowsAsync();
670 testFutureCatchThrowsAsync(); 654 testFutureCatchThrowsAsync();
671 testFutureWhenThrowsAsync(); 655 testFutureWhenThrowsAsync();
672 testFutureCatchRethrowsAsync(); 656 testFutureCatchRethrowsAsync();
673 657
674 testChainedFutureValue(); 658 testChainedFutureValue();
675 testChainedFutureValueDelay(); 659 testChainedFutureValueDelay();
676 testChainedFutureError(); 660 testChainedFutureError();
677 testChainedFutureCycle();
678 } 661 }
OLDNEW
« no previous file with comments | « sdk/lib/async/zone.dart ('k') | tests/lib/async/future_value_chain2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698