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]); |
})); |
})); |
})); |