Index: tests/isolate/request_reply_test.dart |
diff --git a/tests/isolate/request_reply_test.dart b/tests/isolate/request_reply_test.dart |
index b58256922c57cefce11e4f78e2a4928107488eef..f70fb5a9b1b73857407f186fa02e3ffef1062e08 100644 |
--- a/tests/isolate/request_reply_test.dart |
+++ b/tests/isolate/request_reply_test.dart |
@@ -7,28 +7,28 @@ library RequestReplyTest; |
import 'dart:isolate'; |
import '../../pkg/unittest/lib/unittest.dart'; |
-void entry() { |
- port.receive((message, SendPort replyTo) { |
+void entry(initPort) { |
+ ReceivePort port = new ReceivePort(); |
+ initPort.send(port.sendPort); |
+ port.listen((pair) { |
+ var message = pair[0]; |
+ SendPort replyTo = pair[1]; |
replyTo.send(message + 87); |
port.close(); |
}); |
} |
void main() { |
- test("call", () { |
- SendPort port = spawnFunction(entry); |
- port.call(42).then(expectAsync1((message) { |
- expect(message, 42 + 87); |
- })); |
- }); |
- |
test("send", () { |
- SendPort port = spawnFunction(entry); |
- ReceivePort reply = new ReceivePort(); |
- port.send(99, reply.toSendPort()); |
- reply.receive(expectAsync2((message, replyTo) { |
- expect(message, 99 + 87); |
- reply.close(); |
+ ReceivePort init = new ReceivePort(); |
+ Isolate.spawn(entry, init.sendPort); |
+ init.first.then(expectAsync1((port) { |
+ ReceivePort reply = new ReceivePort(); |
+ port.send([99, reply.sendPort]); |
+ reply.listen(expectAsync1((message) { |
+ expect(message, 99 + 87); |
+ reply.close(); |
+ })); |
})); |
}); |
} |