OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:async'; |
| 6 import 'dart:isolate'; |
| 7 |
| 8 testImmediateError() { |
| 9 // An open ReceivePort keeps the VM running. If the error-handler below is not |
| 10 // executed then the test will fail with a timeout. |
| 11 var port = new ReceivePort(); |
| 12 var future = new Future.immediateError("error"); |
| 13 future.catchError((e) { |
| 14 port.close(); |
| 15 Expect.equals(e.error, "error"); |
| 16 }); |
| 17 } |
| 18 |
| 19 Future get completedFuture { |
| 20 var completer = new Completer(); |
| 21 completer.completeError("foobar"); |
| 22 return completer.future; |
| 23 } |
| 24 |
| 25 testDelayedError() { |
| 26 var port = new ReceivePort(); |
| 27 completedFuture.catchError((e) { |
| 28 port.close(); |
| 29 Expect.equals(e.error, "foobar"); |
| 30 }); |
| 31 } |
| 32 |
| 33 main() { |
| 34 testImmediateError(); |
| 35 testDelayedError(); |
| 36 } |
| 37 |
OLD | NEW |