| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; |
| 6 import 'dart:io'; |
| 7 |
| 8 import "package:async_helper/async_helper.dart"; |
| 5 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | |
| 7 import 'dart:isolate'; | |
| 8 import 'dart:io'; | |
| 9 | 10 |
| 10 var events = []; | 11 var events = []; |
| 11 | 12 |
| 12 Future testSocketException() { | 13 Future testSocketException() { |
| 13 var completer = new Completer(); | 14 var completer = new Completer(); |
| 14 runZonedExperimental(() { | 15 runZonedExperimental(() { |
| 15 Socket.connect("4", 1).then((Socket s) { | 16 Socket.connect("4", 1).then((Socket s) { |
| 16 Expect.fail("Socket should not be able to connect"); | 17 Expect.fail("Socket should not be able to connect"); |
| 17 }); | 18 }); |
| 18 }, onError: (err) { | 19 }, onError: (err) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 if (err is! FileException) Expect.fail("Not expected error: $err"); | 32 if (err is! FileException) Expect.fail("Not expected error: $err"); |
| 32 completer.complete("file test, ok."); | 33 completer.complete("file test, ok."); |
| 33 events.add("FileException"); | 34 events.add("FileException"); |
| 34 }); | 35 }); |
| 35 return completer.future; | 36 return completer.future; |
| 36 } | 37 } |
| 37 | 38 |
| 38 main() { | 39 main() { |
| 39 // We keep a ReceivePort open until all tests are done. This way the VM will | 40 // We keep a ReceivePort open until all tests are done. This way the VM will |
| 40 // hang if the callbacks are not invoked and the test will time out. | 41 // hang if the callbacks are not invoked and the test will time out. |
| 41 var timeOutPort = new ReceivePort(); | 42 asyncStart(); |
| 42 testSocketException() | 43 testSocketException() |
| 43 .then((_) => testFileException()) | 44 .then((_) => testFileException()) |
| 44 .then((_) { | 45 .then((_) { |
| 45 timeOutPort.close(); | 46 asyncEnd(); |
| 46 Expect.listEquals(["SocketException", "FileException"], | 47 Expect.listEquals(["SocketException", "FileException"], |
| 47 events); | 48 events); |
| 48 }); | 49 }); |
| 49 } | 50 } |
| OLD | NEW |