blob: 1fe8c3cf6dd698a87200affdedbcf18606b724ab [file] [log] [blame]
/*
* Copyright (c) 2017, 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.
*/
/**
* @assertion Future<int> length
* The number of elements in this stream.
*
* Waits for all elements of this stream. When the stream ends, the returned
* future is completed with the number of elements.
*
* If the stream contains an error, the returned future is completed with that
* error, and processing stops.
*
* This operation listens to the stream, and a non-broadcast stream cannot be
* reused after finding its length.
*
* @description Checks that if this is empty, the returned future completes
* with 0.
* @author ngl@unipro.ru
*/
import "dart:io";
import "../../../Utils/expect.dart";
check(InternetAddress address) {
asyncStart();
SecurityContext sc = new SecurityContext(withTrustedRoots: true);
RawSecureServerSocket.bind(address, 0, sc).then((server) {
server.length.then((value) {
Expect.equals(0, value);
}).whenComplete(() {
asyncEnd();
});
server.close();
});
}
main() {
check(InternetAddress.anyIPv4);
check(InternetAddress.anyIPv6);
check(InternetAddress.loopbackIPv4);
check(InternetAddress.loopbackIPv6);
}