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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 int after1; | 69 int after1; |
70 int after2; | 70 int after2; |
71 | 71 |
72 var futures = []; | 72 var futures = []; |
73 futures.add(future.then((int v) { before = v; })); | 73 futures.add(future.then((int v) { before = v; })); |
74 completer.complete(3); | 74 completer.complete(3); |
75 futures.add(future.then((int v) { after1 = v; })); | 75 futures.add(future.then((int v) { after1 = v; })); |
76 futures.add(future.then((int v) { after2 = v; })); | 76 futures.add(future.then((int v) { after2 = v; })); |
77 | 77 |
78 var port = new ReceivePort(); | 78 var port = new ReceivePort(); |
79 new Future.wait(futures).then((_) { | 79 Future.wait(futures).then((_) { |
80 Expect.equals(3, before); | 80 Expect.equals(3, before); |
81 Expect.equals(3, after1); | 81 Expect.equals(3, after1); |
82 Expect.equals(3, after2); | 82 Expect.equals(3, after2); |
83 port.close(); | 83 port.close(); |
84 }); | 84 }); |
85 } | 85 } |
86 | 86 |
87 // Tests for [catchError] | 87 // Tests for [catchError] |
88 | 88 |
89 testException() { | 89 testException() { |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 testFutureWhenErrorFutureValue(); | 549 testFutureWhenErrorFutureValue(); |
550 testFutureWhenValueFutureError(); | 550 testFutureWhenValueFutureError(); |
551 testFutureWhenErrorFutureError(); | 551 testFutureWhenErrorFutureError(); |
552 | 552 |
553 testFutureThenThrowsAsync(); | 553 testFutureThenThrowsAsync(); |
554 testFutureCatchThrowsAsync(); | 554 testFutureCatchThrowsAsync(); |
555 testFutureWhenThrowsAsync(); | 555 testFutureWhenThrowsAsync(); |
556 testFutureCatchRethrowsAsync(); | 556 testFutureCatchRethrowsAsync(); |
557 } | 557 } |
558 | 558 |
OLD | NEW |