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

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

Issue 204343003: Close(destroy) Socket on user-generated write error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:io"; 5 import "dart:io";
6 6
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 9
10 class NotAnInteger { 10 class NotAnInteger {
(...skipping 12 matching lines...) Expand all
23 Socket.connect(host, port) 23 Socket.connect(host, port)
24 .then((socket) => Expect.fail("Shouldn't get connected")) 24 .then((socket) => Expect.fail("Shouldn't get connected"))
25 .catchError((e) { 25 .catchError((e) {
26 Expect.isTrue(e is ArgumentError || e is SocketException); 26 Expect.isTrue(e is ArgumentError || e is SocketException);
27 asyncEnd(); 27 asyncEnd();
28 }); 28 });
29 } 29 }
30 30
31 testAdd(buffer) { 31 testAdd(buffer) {
32 asyncStart(); 32 asyncStart();
33 asyncStart();
33 ServerSocket.bind("127.0.0.1", 0).then((server) { 34 ServerSocket.bind("127.0.0.1", 0).then((server) {
34 server.listen((socket) => socket.destroy()); 35 server.listen((socket) => socket.destroy());
35 Socket.connect("127.0.0.1", server.port).then((socket) { 36 Socket.connect("127.0.0.1", server.port).then((socket) {
36 int errors = 0; 37 int errors = 0;
37 socket.done.catchError((e) { errors++; }); 38 socket.done
39 .catchError((e) { errors++; })
40 .then((_) {
41 Expect.equals(1, errors);
42 asyncEnd();
43 server.close();
44 });
38 socket.listen( 45 socket.listen(
39 (_) { }, 46 (_) { },
40 onError: (error) { 47 onError: (error) {
41 Expect.fail("Error on stream"); 48 Expect.fail("Error on stream");
42 }, 49 },
43 onDone: () { 50 onDone: () {
44 Expect.equals(1, errors);
45 socket.destroy();
46 server.close();
47 asyncEnd(); 51 asyncEnd();
48 }); 52 });
49 socket.add(buffer); 53 socket.add(buffer);
50 }); 54 });
51 }); 55 });
52 } 56 }
53 57
54 testServerSocketCreation(address, port, backlog) { 58 testServerSocketCreation(address, port, backlog) {
55 asyncStart(); 59 asyncStart();
56 var server; 60 var server;
(...skipping 15 matching lines...) Expand all
72 testAdd(42); 76 testAdd(42);
73 // TODO(8233): Throw ArgumentError from API implementation. 77 // TODO(8233): Throw ArgumentError from API implementation.
74 // testAdd([-1]); 78 // testAdd([-1]);
75 // testAdd([2222222222222222222222222222222]); 79 // testAdd([2222222222222222222222222222222]);
76 // testAdd([1, 2, 3, null]); 80 // testAdd([1, 2, 3, null]);
77 // testAdd([new NotAnInteger()]); 81 // testAdd([new NotAnInteger()]);
78 testServerSocketCreation(123, 123, 123); 82 testServerSocketCreation(123, 123, 123);
79 testServerSocketCreation("string", null, null); 83 testServerSocketCreation("string", null, null);
80 testServerSocketCreation("string", 123, null); 84 testServerSocketCreation("string", 123, null);
81 } 85 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698