| 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 // Tests socket exceptions. | 5 // Tests socket exceptions. |
| 6 | 6 |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 | 9 |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Expect.isFalse(wrongExceptionCaught); | 83 Expect.isFalse(wrongExceptionCaught); |
| 84 try { | 84 try { |
| 85 client.destroy(); | 85 client.destroy(); |
| 86 } on SocketException catch (ex) { | 86 } on SocketException catch (ex) { |
| 87 exceptionCaught = true; | 87 exceptionCaught = true; |
| 88 } catch (ex) { | 88 } catch (ex) { |
| 89 wrongExceptionCaught = true; | 89 wrongExceptionCaught = true; |
| 90 } | 90 } |
| 91 Expect.isFalse(exceptionCaught); | 91 Expect.isFalse(exceptionCaught); |
| 92 Expect.isFalse(wrongExceptionCaught); | 92 Expect.isFalse(wrongExceptionCaught); |
| 93 |
| 94 // From here exceptions are expected. |
| 93 try { | 95 try { |
| 94 List<int> buffer = new List<int>(10); | 96 List<int> buffer = new List<int>(10); |
| 95 client.add(buffer); | 97 client.add(buffer); |
| 96 } on StateError catch (ex) { | 98 } on StateError catch (ex) { |
| 97 exceptionCaught = true; | 99 exceptionCaught = true; |
| 98 } catch (ex) { | 100 } catch (ex) { |
| 99 wrongExceptionCaught = true; | 101 wrongExceptionCaught = true; |
| 100 } | 102 } |
| 101 Expect.isFalse(exceptionCaught); | 103 Expect.isTrue(exceptionCaught); |
| 102 Expect.isFalse(wrongExceptionCaught); | 104 Expect.isFalse(wrongExceptionCaught); |
| 103 | |
| 104 // From here exceptions are expected. | |
| 105 exceptionCaught = false; | 105 exceptionCaught = false; |
| 106 try { | 106 try { |
| 107 client.port; | 107 client.port; |
| 108 } on SocketException catch (ex) { | 108 } on SocketException catch (ex) { |
| 109 exceptionCaught = true; | 109 exceptionCaught = true; |
| 110 } catch (ex) { | 110 } catch (ex) { |
| 111 wrongExceptionCaught = true; | 111 wrongExceptionCaught = true; |
| 112 } | 112 } |
| 113 Expect.isTrue(exceptionCaught); | 113 Expect.isTrue(exceptionCaught); |
| 114 Expect.isFalse(wrongExceptionCaught); | 114 Expect.isFalse(wrongExceptionCaught); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 clientSocketAddCloseResultErrorTest(); | 270 clientSocketAddCloseResultErrorTest(); |
| 271 unknownHostTest(); | 271 unknownHostTest(); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 main() { | 275 main() { |
| 276 asyncStart(); | 276 asyncStart(); |
| 277 SocketExceptionTest.testMain(); | 277 SocketExceptionTest.testMain(); |
| 278 asyncEnd(); | 278 asyncEnd(); |
| 279 } | 279 } |
| OLD | NEW |