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

Side by Side Diff: tests/isolate/src/NestedSpawnTest.dart

Issue 9358010: isolates in frog: playing with API improvements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 8 years, 10 months 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/src/NestedSpawn2Test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Dart test program for testing that isolates can spawn other isolates. 5 // Dart test program for testing that isolates can spawn other isolates.
6 6
7 #library('NestedSpawnTest'); 7 #library('NestedSpawnTest');
8 #import('TestFramework.dart'); 8 #import('TestFramework.dart');
9 9
10 class Isolate1 extends Isolate { 10 class IsolateA extends Isolate {
11 Isolate1() : super.heavy(); 11 IsolateA() : super.heavy();
12 12
13 void main() { 13 void main() {
14 this.port.receive((msg, replyTo) { 14 this.port.receive((msg, replyTo) {
15 Expect.equals("launch nested!", msg); 15 Expect.equals("launch nested!", msg);
16 new Isolate2().spawn().then((SendPort p) { 16 new IsolateB().spawn().then((SendPort p) {
17 p.call("alive?").receive((msg, ignored) { 17 p.call("alive?").receive((msg, ignored) {
18 Expect.equals("and kicking", msg); 18 Expect.equals("and kicking", msg);
19 replyTo.send(499, null); 19 replyTo.send(499, null);
20 this.port.close(); 20 this.port.close();
21 }); 21 });
22 }); 22 });
23 }); 23 });
24 } 24 }
25 } 25 }
26 26
27 class Isolate2 extends Isolate { 27 class IsolateB extends Isolate {
28 Isolate2() : super.heavy(); 28 IsolateB() : super.heavy();
29 29
30 void main() { 30 void main() {
31 this.port.receive((msg, replyTo) { 31 this.port.receive((msg, replyTo) {
32 Expect.equals("alive?", msg); 32 Expect.equals("alive?", msg);
33 replyTo.send("and kicking", null); 33 replyTo.send("and kicking", null);
34 this.port.close(); 34 this.port.close();
35 }); 35 });
36 } 36 }
37 } 37 }
38 38
39 test(TestExpectation expect) { 39 test(TestExpectation expect) {
40 expect.completes(new Isolate1().spawn()).then((SendPort port) { 40 expect.completes(new IsolateA().spawn()).then((SendPort port) {
41 port.call("launch nested!").receive(expect.runs2((msg, ignored) { 41 port.call("launch nested!").receive(expect.runs2((msg, ignored) {
42 Expect.equals(499, msg); 42 Expect.equals(499, msg);
43 expect.succeeded(); 43 expect.succeeded();
44 })); 44 }));
45 }); 45 });
46 } 46 }
47 47
48 main() { 48 main() {
49 runTests([test]); 49 runTests([test]);
50 } 50 }
OLDNEW
« no previous file with comments | « tests/isolate/src/NestedSpawn2Test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698