7df1498352
Change-Id: I5c9080ed75112479ddbeaf6485a5beab3bcb2717 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142209 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Jonas Termansen <sortie@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "dart:io";
|
|
|
|
import "package:async_helper/async_helper.dart";
|
|
import "package:expect/expect.dart";
|
|
|
|
class NotAnInteger {
|
|
operator ==(other) => other == 1;
|
|
operator <(other) => other > 1;
|
|
operator +(other) => 1;
|
|
}
|
|
|
|
testSocketCreation(host, port) {
|
|
asyncStart();
|
|
try {
|
|
Socket.connect(host, port)
|
|
.then((socket) => Expect.fail("Shouldn't get connected"))
|
|
.catchError((e) {
|
|
Expect.isTrue(e is ArgumentError || e is SocketException);
|
|
asyncEnd();
|
|
});
|
|
} catch (e) {
|
|
Expect.isTrue(e is ArgumentError || e is SocketException);
|
|
asyncEnd();
|
|
}
|
|
}
|
|
|
|
testServerSocketCreation(address, port, backlog) {
|
|
asyncStart();
|
|
var server;
|
|
try {
|
|
ServerSocket.bind(address, port, backlog: backlog).then((_) {
|
|
Expect.fail("ServerSocket bound");
|
|
}).catchError((e) => asyncEnd());
|
|
} catch (e) {
|
|
asyncEnd();
|
|
}
|
|
}
|
|
|
|
main() {
|
|
asyncStart();
|
|
testSocketCreation("localhost", -1);
|
|
testSocketCreation("localhost", 65536);
|
|
testServerSocketCreation("string", null, null);
|
|
testServerSocketCreation("string", 123, null);
|
|
testServerSocketCreation("localhost", -1, 123);
|
|
testServerSocketCreation("localhost", 65536, 123);
|
|
asyncEnd();
|
|
}
|