| 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() { |
| 11 final future = new Future<String>.immediate("42"); | 11 final future = new Future<String>.immediate("42"); |
| 12 var port = new ReceivePort(); | 12 var port = new ReceivePort(); |
| 13 future.then((x) { | 13 future.then((x) { |
| 14 Expect.equals("42", x); | 14 Expect.equals("42", x); |
| 15 port.close(); | 15 port.close(); |
| 16 }); | 16 }); |
| 17 } | 17 } |
| 18 | 18 |
| 19 testNeverComplete() { | 19 testNeverComplete() { |
| 20 final completer = new Completer<int>(); | 20 final completer = new Completer<int>(); |
| 21 final future = completer.future; | 21 final future = completer.future; |
| 22 future.then((v) => Except.fails("Value not expected")); | 22 future.then((v) => Expect.fails("Value not expected")); |
| 23 future.catchError((e) => Except.fails("Value not expected")); | 23 future.catchError((e) => Expect.fails("Value not expected")); |
| 24 } | 24 } |
| 25 | 25 |
| 26 testComplete() { | 26 testComplete() { |
| 27 final completer = new Completer<int>(); | 27 final completer = new Completer<int>(); |
| 28 final future = completer.future; | 28 final future = completer.future; |
| 29 | 29 |
| 30 completer.complete(3); | 30 completer.complete(3); |
| 31 | 31 |
| 32 future.then((v) => Expect.equals(3, v)); | 32 future.then((v) => Expect.equals(3, v)); |
| 33 } | 33 } |
| (...skipping 515 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 |