blob: c00895c9ccf86c17ee037627e5e78717e6d6bb70 [file] [log] [blame]
/*
* Copyright (c) 2011, 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 final Future<int> length
* Counts the elements in the stream.
* @description Checks that correct number of elements is returned.
* @author kaigorodov
*/
import "dart:async";
import "../../../Utils/expect.dart";
import "IsolateStream.dart" as IsolateStream;
check(Iterable<int?> data, int expected) {
Stream s = IsolateStream.fromIterable(data);
asyncStart();
s.length.then((value) {
Expect.equals(expected, value);
asyncEnd();
});
}
main() {
check([], 0);
check([1, 2, 3, null], 4);
check(new Iterable.generate(0, (int index) => index * 2), 0);
check(new Iterable.generate(10, (int index) => index * 2), 10);
}