OLD | NEW |
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:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 | 7 |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 if (trace != null) msg += "\nStackTrace: $trace"; | 34 if (trace != null) msg += "\nStackTrace: $trace"; |
35 Expect.fail(msg); | 35 Expect.fail(msg); |
36 }); | 36 }); |
37 } | 37 } |
38 | 38 |
39 // Test two connection after each other. | 39 // Test two connection after each other. |
40 asyncStart(); | 40 asyncStart(); |
41 ServerSocket.bind("127.0.0.1", 0).then((s) { | 41 ServerSocket.bind("127.0.0.1", 0).then((s) { |
42 socket = s; | 42 socket = s; |
43 server = new HttpServer.listenOn(socket); | 43 server = new HttpServer.listenOn(socket); |
| 44 Expect.equals(server.address.address, '127.0.0.1'); |
| 45 Expect.equals(server.address.host, '127.0.0.1'); |
44 server.listen((HttpRequest request) { | 46 server.listen((HttpRequest request) { |
45 request.listen( | 47 request.listen( |
46 (_) {}, | 48 (_) {}, |
47 onDone: () => request.response.close()); | 49 onDone: () => request.response.close()); |
48 }); | 50 }); |
49 | 51 |
50 test(() { | 52 test(() { |
51 test(() { | 53 test(() { |
52 server.close(); | 54 server.close(); |
53 Expect.throws(() => server.port); | 55 Expect.throws(() => server.port); |
| 56 Expect.throws(() => server.address); |
54 socket.close(); | 57 socket.close(); |
55 asyncEnd(); | 58 asyncEnd(); |
56 }); | 59 }); |
57 }); | 60 }); |
58 }); | 61 }); |
59 } | 62 } |
60 | 63 |
61 void main() { | 64 void main() { |
62 testListenOn(); | 65 testListenOn(); |
63 } | 66 } |
OLD | NEW |