mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:21:18 +00:00
6787beb0f6
Otherwise they do not get the right boxing behavior. BUG= R=floitsch@google.com Review URL: https://codereview.chromium.org//964553004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44166 260f80e4-7a28-3924-810f-c04153c831b5
40 lines
907 B
Dart
40 lines
907 B
Dart
// Copyright (c) 2015, 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:async";
|
|
import "package:expect/expect.dart";
|
|
import "package:async_helper/async_helper.dart";
|
|
|
|
sumStream(s) async {
|
|
int accum = 0;
|
|
await for (var v in s) {
|
|
accum += v;
|
|
}
|
|
return accum;
|
|
}
|
|
|
|
test() async {
|
|
var countStreamController;
|
|
int i = 0;
|
|
void tick() {
|
|
if (i < 10) {
|
|
countStreamController.add(i);
|
|
i++;
|
|
scheduleMicrotask(tick);
|
|
} else {
|
|
countStreamController.close();
|
|
}
|
|
}
|
|
|
|
countStreamController = new StreamController(
|
|
onListen: () {
|
|
scheduleMicrotask(tick);
|
|
});
|
|
Expect.equals(45, await sumStream(countStreamController.stream));
|
|
}
|
|
|
|
void main() {
|
|
asyncStart();
|
|
test().then((_) => asyncEnd());
|
|
} |