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

Unified Diff: tests/isolate/request_reply_test.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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/port_test.dart ('k') | tests/isolate/spawn_function_custom_class_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+ }));
}));
});
}
« no previous file with comments | « tests/isolate/port_test.dart ('k') | tests/isolate/spawn_function_custom_class_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698