Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: tests/isolate/count_stream_test.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/isolate/browser/typed_data_message_test.dart ('k') | tests/isolate/count_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library CountTest;
6 import '../../pkg/unittest/lib/unittest.dart';
7 import 'dart:isolate';
8
9 void countMessages() {
10 int count = 0;
11 IsolateSink replySink;
12 bool isFirst = true;
13 stream.listen((msg) {
14 if (isFirst) {
15 replySink = msg;
16 isFirst = false;
17 return;
18 }
19 replySink.add(count);
20 count++;
21 }, onDone: () {
22 expect(count, 10);
23 replySink.close();
24 });
25 }
26
27 void main() {
28 test("count 10 consecutive stream messages", () {
29 int count = 0;
30 MessageBox box = new MessageBox();
31 IsolateSink remote = streamSpawnFunction(countMessages);
32 remote.add(box.sink);
33 box.stream.listen(expectAsync1((remoteCount) {
34 expect(remoteCount, count);
35 count++;
36 if (count < 10) {
37 remote.add(null);
38 } else {
39 remote.close();
40 }
41 }, count: 10), onDone: expectAsync0(() {
42 expect(count, 10);
43 }));
44 remote.add(null);
45 });
46 }
OLDNEW
« no previous file with comments | « tests/isolate/browser/typed_data_message_test.dart ('k') | tests/isolate/count_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698