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

Unified Diff: tests/isolate/src/NestedSpawn2Test.dart

Issue 9652001: SendPort + ReceivePort changes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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/src/MixedTest.dart ('k') | tests/isolate/src/NestedSpawnTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/src/NestedSpawn2Test.dart
diff --git a/tests/isolate/src/NestedSpawn2Test.dart b/tests/isolate/src/NestedSpawn2Test.dart
index 5d4e9aa818855c986257645ea9d8ce1c4008e0c3..38e525c94a80c66e4e8afd45b109316ce7f3f718 100644
--- a/tests/isolate/src/NestedSpawn2Test.dart
+++ b/tests/isolate/src/NestedSpawn2Test.dart
@@ -32,6 +32,15 @@ String msg4 = "4 now?";
String msg5 = "5 Now.";
String msg6 = "6 Great. Bye";
+void _call(SendPort p, msg, void onreceive(m, replyTo)) {
+ final replyTo = new ReceivePort();
+ p.send(msg, replyTo.toSendPort());
+ replyTo.receive((m, r) {
+ replyTo.close();
+ onreceive(m, r);
+ });
+}
+
class IsolateB extends Isolate {
IsolateB() : super.heavy();
@@ -40,33 +49,33 @@ class IsolateB extends Isolate {
this.port.close();
// Do a little ping-pong dance to give the intermediate isolate time to
// die.
- mainPort.call(msg0).receive((msg, replyTo) {
+ _call(mainPort, msg0, ((msg, replyTo) {
Expect.equals("1", msg[0]);
- replyTo.call(msg2).receive((msg, replyTo) {
- Expect.equals("3", msg[0]);
- replyTo.call(msg4).receive((msg, replyTo) {
- Expect.equals("5", msg[0]);
- replyTo.send(msg6, null);
- });
- });
- });
+ _call(replyTo, msg2, ((msg, replyTo) {
+ Expect.equals("3", msg[0]);
+ _call(replyTo, msg4, ((msg, replyTo) {
+ Expect.equals("5", msg[0]);
+ replyTo.send(msg6, null);
+ }));
+ }));
+ }));
});
}
}
test(TestExpectation expect) {
expect.completes(new IsolateA().spawn()).then((SendPort port) {
- port.call("launch nested!").receive(expect.runs2((msg, replyTo) {
+ _call(port, "launch nested!", expect.runs2((msg, replyTo) {
Expect.equals("0", msg[0]);
- replyTo.call(msg1).receive(expect.runs2((msg, replyTo) {
+ _call(replyTo, msg1, expect.runs2((msg, replyTo) {
Expect.equals("2", msg[0]);
- replyTo.call(msg3).receive(expect.runs2((msg, replyTo) {
- Expect.equals("4", msg[0]);
- replyTo.call(msg5).receive(expect.runs2((msg, replyTo) {
- Expect.equals("6", msg[0]);
- expect.succeeded();
- }));
- }));
+ _call(replyTo, msg3, expect.runs2((msg, replyTo) {
+ Expect.equals("4", msg[0]);
+ _call(replyTo, msg5, expect.runs2((msg, replyTo) {
+ Expect.equals("6", msg[0]);
+ expect.succeeded();
+ }));
+ }));
}));
}));
});
« no previous file with comments | « tests/isolate/src/MixedTest.dart ('k') | tests/isolate/src/NestedSpawnTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698