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

Side by Side Diff: tests/isolate/nested_spawn_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/nested_spawn_stream2_test.dart ('k') | tests/isolate/nested_spawn_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 // Dart test program for testing that isolates can spawn other isolates.
6
7 library NestedSpawnTest;
8 import 'dart:isolate';
9 import '../../pkg/unittest/lib/unittest.dart';
10
11 void isolateA() {
12 IsolateSink replyTo;
13 bool isFirst = true;
14 stream.listen((msg) {
15 if (isFirst) {
16 isFirst = false;
17 replyTo = msg;
18 return;
19 }
20 expect(msg, "launch nested!");
21 IsolateSink sink = streamSpawnFunction(isolateB);
22 MessageBox box = new MessageBox();
23 sink.add(box.sink);
24 sink.add("alive?");
25 box.stream.single.then((msg) {
26 expect(msg, "and kicking");
27 replyTo.add(499);
28 replyTo.close();
29 stream.close();
30 });
31 });
32 }
33
34 void isolateB() {
35 IsolateSink replyTo;
36 bool isFirst = true;
37 stream.listen((msg) {
38 if (isFirst) {
39 isFirst = false;
40 replyTo = msg;
41 return;
42 }
43 expect(msg, "alive?");
44 replyTo.add("and kicking");
45 replyTo.close();
46 stream.close();
47 });
48 }
49
50
51 main() {
52 test("spawned isolates can spawn nested isolates", () {
53 MessageBox box = new MessageBox();
54 IsolateSink sink = streamSpawnFunction(isolateA);
55 sink.add(box.sink);
56 sink.add("launch nested!");
57 box.stream.single.then(expectAsync1((msg) {
58 expect(msg, 499);
59 }));
60 });
61 }
OLDNEW
« no previous file with comments | « tests/isolate/nested_spawn_stream2_test.dart ('k') | tests/isolate/nested_spawn_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698