Index: tests/standalone/io/socket_test.dart |
diff --git a/tests/standalone/io/socket_test.dart b/tests/standalone/io/socket_test.dart |
index 0cca8e4ae934812e7fda0f84c224ab879c03dc5b..314e1113924477381ea1b2f1821523e2a052ba85 100644 |
--- a/tests/standalone/io/socket_test.dart |
+++ b/tests/standalone/io/socket_test.dart |
@@ -31,42 +31,39 @@ void testSimpleBind() { |
void testInvalidBind() { |
// Bind to a unknown DNS name. |
asyncStart(); |
- ServerSocket.bind("ko.faar.__hest__", 0) |
- .then((_) { Expect.fail("Failure expected"); } ) |
- .catchError((error) { |
- Expect.isTrue(error is SocketException); |
- asyncEnd(); |
- }); |
+ ServerSocket.bind("ko.faar.__hest__", 0).then((_) { |
+ Expect.fail("Failure expected"); |
+ }).catchError((error) { |
+ Expect.isTrue(error is SocketException); |
+ asyncEnd(); |
+ }); |
// Bind to an unavaliable IP-address. |
asyncStart(); |
- ServerSocket.bind("8.8.8.8", 0) |
- .then((_) { Expect.fail("Failure expected"); } ) |
- .catchError((error) { |
- Expect.isTrue(error is SocketException); |
- asyncEnd(); |
- }); |
+ ServerSocket.bind("8.8.8.8", 0).then((_) { |
+ Expect.fail("Failure expected"); |
+ }).catchError((error) { |
+ Expect.isTrue(error is SocketException); |
+ asyncEnd(); |
+ }); |
// Bind to a port already in use. |
asyncStart(); |
- ServerSocket.bind("127.0.0.1", 0) |
- .then((s) { |
- ServerSocket.bind("127.0.0.1", s.port) |
- .then((t) { |
- Expect.fail("Multiple listens on same port"); |
- }) |
- .catchError((error) { |
- Expect.isTrue(error is SocketException); |
- s.close(); |
- asyncEnd(); |
- }); |
- }); |
+ ServerSocket.bind("127.0.0.1", 0).then((s) { |
+ ServerSocket.bind("127.0.0.1", s.port).then((t) { |
+ Expect.fail("Multiple listens on same port"); |
+ }).catchError((error) { |
+ Expect.isTrue(error is SocketException); |
+ s.close(); |
+ asyncEnd(); |
+ }); |
+ }); |
} |
void testConnectImmediateDestroy() { |
asyncStart(); |
ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
- server.listen((_) { }); |
+ server.listen((_) {}); |
Socket.connect("127.0.0.1", server.port).then((socket) { |
socket.destroy(); |
server.close(); |
@@ -80,7 +77,7 @@ void testConnectConsumerClose() { |
// listening on the stream. |
asyncStart(); |
ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
- server.listen((_) { }); |
+ server.listen((_) {}); |
Socket.connect("127.0.0.1", server.port).then((socket) { |
socket.close(); |
socket.done.then((_) { |
@@ -97,7 +94,7 @@ void testConnectConsumerWriteClose() { |
// without listening on the stream. |
asyncStart(); |
ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
- server.listen((_) { }); |
+ server.listen((_) {}); |
Socket.connect("127.0.0.1", server.port).then((socket) { |
socket.add([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); |
socket.close(); |
@@ -116,19 +113,20 @@ void testConnectStreamClose() { |
asyncStart(); |
ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
server.listen((client) { |
- client.close(); |
- client.done.then((_) => client.destroy()); |
- }); |
+ client.close(); |
+ client.done.then((_) => client.destroy()); |
+ }); |
Socket.connect("127.0.0.1", server.port).then((socket) { |
- bool onDoneCalled = false; |
- socket.listen((_) { Expect.fail("Unexpected data"); }, |
- onDone: () { |
- Expect.isFalse(onDoneCalled); |
- onDoneCalled = true; |
- socket.close(); |
- server.close(); |
- asyncEnd(); |
- }); |
+ bool onDoneCalled = false; |
+ socket.listen((_) { |
+ Expect.fail("Unexpected data"); |
+ }, onDone: () { |
+ Expect.isFalse(onDoneCalled); |
+ onDoneCalled = true; |
+ socket.close(); |
+ server.close(); |
+ asyncEnd(); |
+ }); |
}); |
}); |
} |
@@ -139,29 +137,31 @@ void testConnectStreamDataClose(bool useDestroy) { |
List<int> sendData = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
asyncStart(); |
ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
- server.listen( |
- (client) { |
- client.add(sendData); |
- if (useDestroy) { |
- client.destroy(); |
- } else { |
- client.close(); |
- } |
- client.done.then((_) { if (!useDestroy) { client.destroy(); } }); |
- }); |
+ server.listen((client) { |
+ client.add(sendData); |
+ if (useDestroy) { |
+ client.destroy(); |
+ } else { |
+ client.close(); |
+ } |
+ client.done.then((_) { |
+ if (!useDestroy) { |
+ client.destroy(); |
+ } |
+ }); |
+ }); |
Socket.connect("127.0.0.1", server.port).then((socket) { |
- List<int> data = []; |
- bool onDoneCalled = false; |
- socket.listen(data.addAll, |
- onDone: () { |
- Expect.isFalse(onDoneCalled); |
- onDoneCalled = true; |
- if (!useDestroy) Expect.listEquals(sendData, data); |
- socket.add([0]); |
- socket.close(); |
- server.close(); |
- asyncEnd(); |
- }); |
+ List<int> data = []; |
+ bool onDoneCalled = false; |
+ socket.listen(data.addAll, onDone: () { |
+ Expect.isFalse(onDoneCalled); |
+ onDoneCalled = true; |
+ if (!useDestroy) Expect.listEquals(sendData, data); |
+ socket.add([0]); |
+ socket.close(); |
+ server.close(); |
+ asyncEnd(); |
+ }); |
}); |
}); |
} |
@@ -170,32 +170,29 @@ void testConnectStreamDataCloseCancel(bool useDestroy) { |
List<int> sendData = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
asyncStart(); |
ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0).then((server) { |
- server.listen( |
- (client) { |
- client.add(sendData); |
- if (useDestroy) { |
- client.destroy(); |
- } else { |
- client.close(); |
- } |
- client.done |
- .then((_) { |
- if (!useDestroy) client.destroy(); |
- }) |
- .catchError((e) { /* can happen with short writes */ }); |
- }); |
+ server.listen((client) { |
+ client.add(sendData); |
+ if (useDestroy) { |
+ client.destroy(); |
+ } else { |
+ client.close(); |
+ } |
+ client.done.then((_) { |
+ if (!useDestroy) client.destroy(); |
+ }).catchError((e) {/* can happen with short writes */}); |
+ }); |
Socket.connect("127.0.0.1", server.port).then((socket) { |
- List<int> data = []; |
- bool onDoneCalled = false; |
- var subscription; |
- subscription = socket.listen( |
- (_) { |
- subscription.cancel(); |
- socket.close(); |
- server.close(); |
- asyncEnd(); |
- }, |
- onDone: () { Expect.fail("Unexpected pipe completion"); }); |
+ List<int> data = []; |
+ bool onDoneCalled = false; |
+ var subscription; |
+ subscription = socket.listen((_) { |
+ subscription.cancel(); |
+ socket.close(); |
+ server.close(); |
+ asyncEnd(); |
+ }, onDone: () { |
+ Expect.fail("Unexpected pipe completion"); |
+ }); |
}); |
}); |
} |