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

Unified Diff: tests/isolate/message2_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/mandel_isolate_test.dart ('k') | tests/isolate/message_stream2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/message2_test.dart
diff --git a/tests/isolate/message2_test.dart b/tests/isolate/message2_test.dart
index 07b34e6716bc020ba7722c64d7a05b96ec98626e..334ae0431194da2bdbbf5e0ff2cc5f299cc65c04 100644
--- a/tests/isolate/message2_test.dart
+++ b/tests/isolate/message2_test.dart
@@ -41,29 +41,36 @@ class MessageTest {
}
}
-void pingPong() {
- port.receive((var message, SendPort replyTo) {
- if (message == -1) {
+void pingPong(replyPort) {
+ ReceivePort port = new ReceivePort();
+ port.listen((message) {
+ if (message == null) {
port.close();
} else {
// Bounce the received object back so that the sender
// can make sure that the object matches.
- replyTo.send(message, null);
+ message[1].send(message[0]);
}
});
+ replyPort.send(port.sendPort);
}
main() {
test("map is equal after it is sent back and forth", () {
- SendPort remote = spawnFunction(pingPong);
- Map m = new Map();
- m[1] = "eins";
- m[2] = "deux";
- m[3] = "tre";
- m[4] = "four";
- remote.call(m).then(expectAsync1((var received) {
- MessageTest.mapEqualsDeep(m, received);
- remote.send(-1, null);
+ ReceivePort port = new ReceivePort();
+ Isolate.spawn(pingPong, port.sendPort);
+ port.first.then(expectAsync1((remote) {
+ Map m = new Map();
+ m[1] = "eins";
+ m[2] = "deux";
+ m[3] = "tre";
+ m[4] = "four";
+ ReceivePort replyPort = new ReceivePort();
+ remote.send([m, replyPort.sendPort]);
+ replyPort.first.then(expectAsync1((var received) {
+ MessageTest.mapEqualsDeep(m, received);
+ remote.send(null);
+ }));
}));
});
}
« no previous file with comments | « tests/isolate/mandel_isolate_test.dart ('k') | tests/isolate/message_stream2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698