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

Unified Diff: tests/isolate/nested_spawn2_test.dart

Issue 10837070: Remove old isolate API and update all code in the repository to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/isolate/mixed_test.dart ('k') | tests/isolate/nested_spawn_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/nested_spawn2_test.dart
diff --git a/tests/isolate/nested_spawn2_test.dart b/tests/isolate/nested_spawn2_test.dart
index 8340ae5ef9f5e6691ec679d17f7407b3e212ee88..141e0fbcbf072b72b04c8297ddc77d96f55bd37c 100644
--- a/tests/isolate/nested_spawn2_test.dart
+++ b/tests/isolate/nested_spawn2_test.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// 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.
@@ -10,18 +10,13 @@
#import("dart:isolate");
#import('../../lib/unittest/unittest.dart');
-class IsolateA extends Isolate {
- IsolateA() : super.heavy();
-
- void main() {
- this.port.receive((msg, replyTo) {
- Expect.equals("launch nested!", msg);
- new IsolateB().spawn().then((SendPort p) {
- p.send(replyTo, null);
- this.port.close();
- });
- });
- }
+void isolateA() {
+ port.receive((msg, replyTo) {
+ Expect.equals("launch nested!", msg);
+ SendPort p = spawnFunction(isolateB);
+ p.send(replyTo, null);
+ port.close();
+ });
}
String msg0 = "0 there?";
@@ -41,40 +36,35 @@ void _call(SendPort p, msg, void onreceive(m, replyTo)) {
});
}
-class IsolateB extends Isolate {
- IsolateB() : super.heavy();
-
- void main() {
- this.port.receive((mainPort, replyTo) {
- this.port.close();
- // Do a little ping-pong dance to give the intermediate isolate time to
- // die.
- _call(mainPort, msg0, ((msg, replyTo) {
- Expect.equals("1", msg[0]);
- _call(replyTo, msg2, ((msg, replyTo) {
- Expect.equals("3", msg[0]);
- _call(replyTo, msg4, ((msg, replyTo) {
- Expect.equals("5", msg[0]);
- replyTo.send(msg6, null);
- }));
+void isolateB() {
+ port.receive((mainPort, replyTo) {
+ port.close();
+ // Do a little ping-pong dance to give the intermediate isolate
+ // time to die.
+ _call(mainPort, msg0, ((msg, replyTo) {
+ Expect.equals("1", msg[0]);
+ _call(replyTo, msg2, ((msg, replyTo) {
+ Expect.equals("3", msg[0]);
+ _call(replyTo, msg4, ((msg, replyTo) {
+ Expect.equals("5", msg[0]);
+ replyTo.send(msg6, null);
}));
}));
- });
- }
+ }));
+ });
}
main() {
test("spawned isolate can spawn other isolates", () {
- new IsolateA().spawn().then(expectAsync1((SendPort port) {
- _call(port, "launch nested!", expectAsync2((msg, replyTo) {
- Expect.equals("0", msg[0]);
- _call(replyTo, msg1, expectAsync2((msg, replyTo) {
- Expect.equals("2", msg[0]);
- _call(replyTo, msg3, expectAsync2((msg, replyTo) {
- Expect.equals("4", msg[0]);
- _call(replyTo, msg5, expectAsync2((msg, replyTo) {
- Expect.equals("6", msg[0]);
- }));
+ SendPort port = spawnFunction(isolateA);
+ _call(port, "launch nested!", expectAsync2((msg, replyTo) {
+ Expect.equals("0", msg[0]);
+ _call(replyTo, msg1, expectAsync2((msg, replyTo) {
+ Expect.equals("2", msg[0]);
+ _call(replyTo, msg3, expectAsync2((msg, replyTo) {
+ Expect.equals("4", msg[0]);
+ _call(replyTo, msg5, expectAsync2((msg, replyTo) {
+ Expect.equals("6", msg[0]);
}));
}));
}));
« no previous file with comments | « tests/isolate/mixed_test.dart ('k') | tests/isolate/nested_spawn_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698