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

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

Issue 14690009: Make Completers asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 7 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
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:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 future.then((v) => Expect.equals(3, v)); 70 future.then((v) => Expect.equals(3, v));
71 } 71 }
72 72
73 // Tests for [then] 73 // Tests for [then]
74 74
75 testCompleteWithSuccessHandlerBeforeComplete() { 75 testCompleteWithSuccessHandlerBeforeComplete() {
76 final completer = new Completer<int>(); 76 final completer = new Completer<int>();
77 final future = completer.future; 77 final future = completer.future;
78 78
79 int value; 79 int after;
80 future.then((int v) { value = v; });
81 Expect.isNull(value);
82 80
83 Expect.isFalse(completer.isCompleted); 81 var port = new ReceivePort();
82 future.then((int v) { after = v; })
83 .then((_) {
84 Expect.equals(3, after);
85 port.close();
86 });
87
84 completer.complete(3); 88 completer.complete(3);
85 Expect.isTrue(completer.isCompleted); 89 Expect.isNull(after);
86
87 Expect.equals(3, value);
88 } 90 }
89 91
90 testCompleteWithSuccessHandlerAfterComplete() { 92 testCompleteWithSuccessHandlerAfterComplete() {
91 final completer = new Completer<int>(); 93 final completer = new Completer<int>();
92 final future = completer.future; 94 final future = completer.future;
93 95
94 int after; 96 int after;
95 completer.complete(3); 97 completer.complete(3);
96 Expect.isNull(after); 98 Expect.isNull(after);
97 99
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 testFutureCatchThrowsAsync(); 653 testFutureCatchThrowsAsync();
652 testFutureWhenThrowsAsync(); 654 testFutureWhenThrowsAsync();
653 testFutureCatchRethrowsAsync(); 655 testFutureCatchRethrowsAsync();
654 656
655 testChainedFutureValue(); 657 testChainedFutureValue();
656 testChainedFutureValueDelay(); 658 testChainedFutureValueDelay();
657 testChainedFutureError(); 659 testChainedFutureError();
658 } 660 }
659 661
660 662
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698