OLD | NEW |
1 #import("dart:io"); | 1 #import("dart:io"); |
2 #import("dart:isolate"); | 2 #import("dart:isolate"); |
3 | 3 |
4 void sendData(List<int> data, int port) { | 4 void sendData(List<int> data, int port) { |
5 Socket socket = new Socket("127.0.0.1", port); | 5 Socket socket = new Socket("127.0.0.1", port); |
6 socket.onConnect = () { | 6 socket.onConnect = () { |
7 socket.onData = () { | 7 socket.onData = () { |
8 Expect.fail("No data response was expected"); | 8 Expect.fail("No data response was expected"); |
9 }; | 9 }; |
10 socket.outputStream.onNoPendingWrites = () { | 10 socket.outputStream.onNoPendingWrites = () { |
(...skipping 25 matching lines...) Expand all Loading... |
36 Expect.isFalse(calledOnError); | 36 Expect.isFalse(calledOnError); |
37 Expect.equals(exception, error.message); | 37 Expect.equals(exception, error.message); |
38 Expect.equals(expectRequest, calledOnRequest); | 38 Expect.equals(expectRequest, calledOnRequest); |
39 calledOnError = true; | 39 calledOnError = true; |
40 port.close(); | 40 port.close(); |
41 c.complete(null); | 41 c.complete(null); |
42 }; | 42 }; |
43 | 43 |
44 List<int> d; | 44 List<int> d; |
45 if (data is List<int>) d = data; | 45 if (data is List<int>) d = data; |
46 if (data is String) d = data.charCodes(); | 46 if (data is String) d = data.charCodes; |
47 if (d == null) Expect.fail("Invalid data"); | 47 if (d == null) Expect.fail("Invalid data"); |
48 sendData(d, server.port); | 48 sendData(d, server.port); |
49 | 49 |
50 return c.future; | 50 return c.future; |
51 } | 51 } |
52 | 52 |
53 final data; | 53 final data; |
54 final String exception; | 54 final String exception; |
55 final bool expectRequest; | 55 final bool expectRequest; |
56 } | 56 } |
(...skipping 28 matching lines...) Expand all Loading... |
85 } else { | 85 } else { |
86 server.close(); | 86 server.close(); |
87 } | 87 } |
88 } | 88 } |
89 runTest(tests.iterator()); | 89 runTest(tests.iterator()); |
90 } | 90 } |
91 | 91 |
92 void main() { | 92 void main() { |
93 testEarlyClose(); | 93 testEarlyClose(); |
94 } | 94 } |
OLD | NEW |