Chromium Code Reviews| Index: tests/isolate/count_stream_test.dart |
| diff --git a/tests/isolate/count_stream_test.dart b/tests/isolate/count_stream_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7c1ace62115a5a425239053bcd62d7faf401c87e |
| --- /dev/null |
| +++ b/tests/isolate/count_stream_test.dart |
| @@ -0,0 +1,46 @@ |
| +// Copyright (c) 2012, 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. |
| + |
| +library CountTest; |
| +import '../../pkg/unittest/lib/unittest.dart'; |
| +import 'dart:isolate'; |
| + |
| +void countMessages() { |
| + int count = 0; |
| + IsolateSink replySink; |
| + bool isFirst = true; |
| + stream.listen((msg) { |
|
Lasse Reichstein Nielsen
2013/03/19 12:01:55
Where is "stream" declared?
floitsch
2013/03/19 13:18:59
Top level from async.
|
| + if (isFirst) { |
| + replySink = msg; |
| + isFirst = false; |
| + return; |
| + } |
| + replySink.add(count); |
| + count++; |
| + }, onDone: () { |
| + expect(count, 10); |
| + replySink.close(); |
| + }); |
| +} |
| + |
| +void main() { |
| + test("count 10 consecutive stream messages", () { |
| + int count = 0; |
| + MessageBox box = new MessageBox(); |
| + IsolateSink remote = streamSpawnFunction(countMessages); |
| + remote.add(box.sink); |
| + box.stream.listen(expectAsync1((remoteCount) { |
| + expect(remoteCount, count); |
| + count++; |
| + if (count < 10) { |
| + remote.add(count); |
|
Lasse Reichstein Nielsen
2013/03/19 12:01:55
Don't send "count" here. Just send null. It looks
floitsch
2013/03/19 13:18:59
Done.
|
| + } else { |
| + remote.close(); |
| + } |
| + }, count: 10), onDone: expectAsync0(() { |
| + expect(count, 10); |
| + })); |
| + remote.add(0); |
|
Lasse Reichstein Nielsen
2013/03/19 12:01:55
Send null.
floitsch
2013/03/19 13:18:59
Done.
|
| + }); |
| +} |