| 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 // Regression test for http://code.google.com/p/dart/issues/detail?id=1925. | |
| 6 // | |
| 7 // VMOptions= | |
| 8 // VMOptions=--short_socket_read | |
| 9 // VMOptions=--short_socket_write | |
| 10 // VMOptions=--short_socket_read --short_socket_write | |
| 11 library ServerTest; | |
| 12 | |
| 13 import "dart:io"; | |
| 14 import "dart:isolate"; | |
| 15 part "testing_server.dart"; | |
| 16 | |
| 17 class Regress1925TestServer extends TestingServer { | |
| 18 | |
| 19 void onConnection(Socket socket) { | |
| 20 socket.onError = (e) => Expect.fail("Server socket error $e"); | |
| 21 socket.inputStream.onClosed = () => socket.outputStream.close(); | |
| 22 socket.inputStream.onData = () { | |
| 23 var buffer = new List(1); | |
| 24 var read = socket.inputStream.readInto(buffer); | |
| 25 Expect.equals(1, read); | |
| 26 socket.outputStream.writeFrom(buffer, 0, read); | |
| 27 }; | |
| 28 } | |
| 29 | |
| 30 int _connections = 0; | |
| 31 } | |
| 32 | |
| 33 | |
| 34 class Regress1925Test extends TestingServerTest { | |
| 35 Regress1925Test.start() : super.start(new Regress1925TestServer()); | |
| 36 | |
| 37 void run() { | |
| 38 | |
| 39 var count = 0; | |
| 40 var buffer = new List(5); | |
| 41 Socket socket = new Socket(TestingServer.HOST, _port); | |
| 42 socket.onConnect = () { | |
| 43 socket.outputStream.write("12345".charCodes); | |
| 44 socket.outputStream.close(); | |
| 45 socket.inputStream.onData = () { | |
| 46 count += socket.inputStream.readInto(buffer, count); | |
| 47 }; | |
| 48 socket.inputStream.onClosed = () { | |
| 49 Expect.equals(5, count); | |
| 50 shutdown(); | |
| 51 }; | |
| 52 socket.inputStream.onError = (e) => Expect.fail("Socket error $e"); | |
| 53 }; | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 main() { | |
| 58 Regress1925Test test = new Regress1925Test.start(); | |
| 59 } | |
| OLD | NEW |