Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/standalone/io/socket_exception_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Tests socket exceptions. 5 // Tests socket exceptions.
6 6
7 import "dart:isolate"; 7 import "dart:isolate";
8 import "dart:io"; 8 import "dart:io";
9 9
10 class SocketExceptionTest { 10 class SocketExceptionTest {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 client.available(); 61 client.available();
62 } on SocketIOException catch(ex) { 62 } on SocketIOException catch(ex) {
63 exceptionCaught = true; 63 exceptionCaught = true;
64 } on Exception catch (ex) { 64 } on Exception catch (ex) {
65 wrongExceptionCaught = true; 65 wrongExceptionCaught = true;
66 } 66 }
67 Expect.equals(true, exceptionCaught); 67 Expect.equals(true, exceptionCaught);
68 Expect.equals(true, !wrongExceptionCaught); 68 Expect.equals(true, !wrongExceptionCaught);
69 exceptionCaught = false; 69 exceptionCaught = false;
70 try { 70 try {
71 List<int> buffer = new List<int>(10); 71 List<int> buffer = new List<int>.fixedLength(10);
72 client.readList(buffer, 0 , 10); 72 client.readList(buffer, 0 , 10);
73 } on SocketIOException catch(ex) { 73 } on SocketIOException catch(ex) {
74 exceptionCaught = true; 74 exceptionCaught = true;
75 } on Exception catch (ex) { 75 } on Exception catch (ex) {
76 wrongExceptionCaught = true; 76 wrongExceptionCaught = true;
77 } 77 }
78 Expect.equals(true, exceptionCaught); 78 Expect.equals(true, exceptionCaught);
79 Expect.equals(true, !wrongExceptionCaught); 79 Expect.equals(true, !wrongExceptionCaught);
80 exceptionCaught = false; 80 exceptionCaught = false;
81 try { 81 try {
82 List<int> buffer = new List<int>(10); 82 List<int> buffer = new List<int>.fixedLength(10);
83 client.writeList(buffer, 0, 10); 83 client.writeList(buffer, 0, 10);
84 } on SocketIOException catch(ex) { 84 } on SocketIOException catch(ex) {
85 exceptionCaught = true; 85 exceptionCaught = true;
86 } on Exception catch (ex) { 86 } on Exception catch (ex) {
87 wrongExceptionCaught = true; 87 wrongExceptionCaught = true;
88 } 88 }
89 Expect.equals(true, exceptionCaught); 89 Expect.equals(true, exceptionCaught);
90 Expect.equals(true, !wrongExceptionCaught); 90 Expect.equals(true, !wrongExceptionCaught);
91 exceptionCaught = false; 91 exceptionCaught = false;
92 try { 92 try {
93 List<int> buffer = new List<int>(42); 93 List<int> buffer = new List<int>.fixedLength(42);
94 input.readInto(buffer, 0, 12); 94 input.readInto(buffer, 0, 12);
95 } on SocketIOException catch(ex) { 95 } on SocketIOException catch(ex) {
96 exceptionCaught = true; 96 exceptionCaught = true;
97 } on Exception catch (ex) { 97 } on Exception catch (ex) {
98 wrongExceptionCaught = true; 98 wrongExceptionCaught = true;
99 } 99 }
100 Expect.equals(true, exceptionCaught); 100 Expect.equals(true, exceptionCaught);
101 Expect.equals(true, !wrongExceptionCaught); 101 Expect.equals(true, !wrongExceptionCaught);
102 exceptionCaught = false; 102 exceptionCaught = false;
103 try { 103 try {
104 List<int> buffer = new List<int>(42); 104 List<int> buffer = new List<int>.fixedLength(42);
105 output.writeFrom(buffer, 0, 12); 105 output.writeFrom(buffer, 0, 12);
106 } on SocketIOException catch(ex) { 106 } on SocketIOException catch(ex) {
107 exceptionCaught = true; 107 exceptionCaught = true;
108 } on Exception catch (ex) { 108 } on Exception catch (ex) {
109 wrongExceptionCaught = true; 109 wrongExceptionCaught = true;
110 } 110 }
111 Expect.equals(true, exceptionCaught); 111 Expect.equals(true, exceptionCaught);
112 Expect.equals(true, !wrongExceptionCaught); 112 Expect.equals(true, !wrongExceptionCaught);
113 113
114 server.close(); 114 server.close();
115 }; 115 };
116 } 116 }
117 117
118 static void indexOutOfRangeExceptionTest() { 118 static void indexOutOfRangeExceptionTest() {
119 bool exceptionCaught = false; 119 bool exceptionCaught = false;
120 bool wrongExceptionCaught = false; 120 bool wrongExceptionCaught = false;
121 121
122 ServerSocket server = new ServerSocket(HOST, PORT, 10); 122 ServerSocket server = new ServerSocket(HOST, PORT, 10);
123 Expect.equals(true, server != null); 123 Expect.equals(true, server != null);
124 int port = server.port; 124 int port = server.port;
125 Socket client = new Socket(HOST, port); 125 Socket client = new Socket(HOST, port);
126 client.onConnect = () { 126 client.onConnect = () {
127 Expect.equals(true, client != null); 127 Expect.equals(true, client != null);
128 try { 128 try {
129 List<int> buffer = new List<int>(10); 129 List<int> buffer = new List<int>.fixedLength(10);
130 client.readList(buffer, -1, 1); 130 client.readList(buffer, -1, 1);
131 } on RangeError catch (ex) { 131 } on RangeError catch (ex) {
132 exceptionCaught = true; 132 exceptionCaught = true;
133 } on Exception catch (ex) { 133 } on Exception catch (ex) {
134 wrongExceptionCaught = true; 134 wrongExceptionCaught = true;
135 } 135 }
136 Expect.equals(true, exceptionCaught); 136 Expect.equals(true, exceptionCaught);
137 Expect.equals(true, !wrongExceptionCaught); 137 Expect.equals(true, !wrongExceptionCaught);
138 exceptionCaught = false; 138 exceptionCaught = false;
139 139
140 try { 140 try {
141 List<int> buffer = new List<int>(10); 141 List<int> buffer = new List<int>.fixedLength(10);
142 client.readList(buffer, 0, -1); 142 client.readList(buffer, 0, -1);
143 } on RangeError catch (ex) { 143 } on RangeError catch (ex) {
144 exceptionCaught = true; 144 exceptionCaught = true;
145 } on Exception catch (ex) { 145 } on Exception catch (ex) {
146 wrongExceptionCaught = true; 146 wrongExceptionCaught = true;
147 } 147 }
148 Expect.equals(true, exceptionCaught); 148 Expect.equals(true, exceptionCaught);
149 Expect.equals(true, !wrongExceptionCaught); 149 Expect.equals(true, !wrongExceptionCaught);
150 exceptionCaught = false; 150 exceptionCaught = false;
151 151
152 try { 152 try {
153 List<int> buffer = new List<int>(10); 153 List<int> buffer = new List<int>.fixedLength(10);
154 client.writeList(buffer, -1, 1); 154 client.writeList(buffer, -1, 1);
155 } on RangeError catch (ex) { 155 } on RangeError catch (ex) {
156 exceptionCaught = true; 156 exceptionCaught = true;
157 } on Exception catch (ex) { 157 } on Exception catch (ex) {
158 wrongExceptionCaught = true; 158 wrongExceptionCaught = true;
159 } 159 }
160 Expect.equals(true, exceptionCaught); 160 Expect.equals(true, exceptionCaught);
161 Expect.equals(true, !wrongExceptionCaught); 161 Expect.equals(true, !wrongExceptionCaught);
162 exceptionCaught = false; 162 exceptionCaught = false;
163 163
164 try { 164 try {
165 List<int> buffer = new List<int>(10); 165 List<int> buffer = new List<int>.fixedLength(10);
166 client.writeList(buffer, 0, -1); 166 client.writeList(buffer, 0, -1);
167 } on RangeError catch (ex) { 167 } on RangeError catch (ex) {
168 exceptionCaught = true; 168 exceptionCaught = true;
169 } on Exception catch (ex) { 169 } on Exception catch (ex) {
170 wrongExceptionCaught = true; 170 wrongExceptionCaught = true;
171 } 171 }
172 Expect.equals(true, exceptionCaught); 172 Expect.equals(true, exceptionCaught);
173 Expect.equals(true, !wrongExceptionCaught); 173 Expect.equals(true, !wrongExceptionCaught);
174 174
175 server.close(); 175 server.close();
(...skipping 16 matching lines...) Expand all
192 clientSocketExceptionTest(); 192 clientSocketExceptionTest();
193 indexOutOfRangeExceptionTest(); 193 indexOutOfRangeExceptionTest();
194 unknownHostTest(); 194 unknownHostTest();
195 } 195 }
196 } 196 }
197 197
198 main() { 198 main() {
199 SocketExceptionTest.testMain(); 199 SocketExceptionTest.testMain();
200 } 200 }
201 201
OLDNEW
« no previous file with comments | « tests/standalone/io/socket_close_test.dart ('k') | tests/standalone/io/socket_many_connections_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698