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

Side by Side Diff: tests/standalone/src/io/Regress-1925.dart

Issue 10035056: Fix a number of editor errors and warnings in io tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 // Regression test for http://code.google.com/p/dart/issues/detail?id=1925. 5 // Regression test for http://code.google.com/p/dart/issues/detail?id=1925.
6 // 6 //
7 // VMOptions= 7 // VMOptions=
8 // VMOptions=--short_socket_read 8 // VMOptions=--short_socket_read
9 // VMOptions=--short_socket_write 9 // VMOptions=--short_socket_write
10 // VMOptions=--short_socket_read --short_socket_write 10 // VMOptions=--short_socket_read --short_socket_write
11 11
12 #import("dart:io"); 12 #import("dart:io");
13 #import("dart:isolate"); 13 #import("dart:isolate");
14 #source("TestingServer.dart"); 14 #source("TestingServer.dart");
15 15
16 final CONNECTIONS = 200;
17
18 class Regress1925TestServer extends TestingServer { 16 class Regress1925TestServer extends TestingServer {
19 17
20 void onConnection(Socket socket) { 18 void onConnection(Socket socket) {
21 socket.onError = () => Expect.fail("Server socket error"); 19 socket.onError = (e) => Expect.fail("Server socket error $e");
22 socket.inputStream.onClosed = () => socket.outputStream.close(); 20 socket.inputStream.onClosed = () => socket.outputStream.close();
23 socket.inputStream.onData = () { 21 socket.inputStream.onData = () {
24 var buffer = new List(1); 22 var buffer = new List(1);
25 var read = socket.inputStream.readInto(buffer); 23 var read = socket.inputStream.readInto(buffer);
26 Expect.equals(1, read); 24 Expect.equals(1, read);
27 socket.outputStream.writeFrom(buffer, 0, read); 25 socket.outputStream.writeFrom(buffer, 0, read);
28 }; 26 };
29 } 27 }
30 28
31 int _connections = 0; 29 int _connections = 0;
32 } 30 }
33 31
34 32
35 class Regress1925Test extends TestingServerTest { 33 class Regress1925Test extends TestingServerTest {
36 Regress1925Test.start() : super.start(new Regress1925TestServer()); 34 Regress1925Test.start() : super.start(new Regress1925TestServer());
37 35
38 void run() { 36 void run() {
39 37
40 void onConnect() {
41 _connections++;
42 if (_connections == CONNECTIONS) {
43 for (int i = 0; i < CONNECTIONS; i++) {
44 _sockets[i].close();
45 }
46 shutdown();
47 }
48 }
49
50 var count = 0; 38 var count = 0;
51 var buffer = new List(5); 39 var buffer = new List(5);
52 Socket socket = new Socket(TestingServer.HOST, _port); 40 Socket socket = new Socket(TestingServer.HOST, _port);
53 socket.onConnect = () { 41 socket.onConnect = () {
54 socket.outputStream.write("12345".charCodes()); 42 socket.outputStream.write("12345".charCodes());
55 socket.outputStream.close(); 43 socket.outputStream.close();
56 socket.inputStream.onData = () { 44 socket.inputStream.onData = () {
57 count += socket.inputStream.readInto(buffer, count); 45 count += socket.inputStream.readInto(buffer, count);
58 }; 46 };
59 socket.inputStream.onClosed = () { 47 socket.inputStream.onClosed = () {
60 Expect.equals(5, count); 48 Expect.equals(5, count);
61 shutdown(); 49 shutdown();
62 }; 50 };
63 socket.inputStream.onError = () => Expect.fail("Socket error"); 51 socket.inputStream.onError = (e) => Expect.fail("Socket error $e");
64 }; 52 };
65 } 53 }
66 } 54 }
67 55
68 main() { 56 main() {
69 Regress1925Test test = new Regress1925Test.start(); 57 Regress1925Test test = new Regress1925Test.start();
70 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698