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

Unified Diff: tests/language/typed_message_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/unresolved_ports_test.dart ('k') | tests/lib/analyzer/analyze_tests.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/typed_message_test.dart
diff --git a/tests/language/typed_message_test.dart b/tests/language/typed_message_test.dart
index 0904faef0d1ec619fece369a67b76c041a7b746f..e034d3ed40e2f43de1af359086c98fbf1cac4019 100644
--- a/tests/language/typed_message_test.dart
+++ b/tests/language/typed_message_test.dart
@@ -6,12 +6,15 @@
// VMOptions=--checked
library TypedMessageTest;
+import "dart:async";
import "package:expect/expect.dart";
import "dart:isolate";
-void logMessages() {
+void logMessages(SendPort replyTo) {
print("Starting log server.");
- port.receive((List<int> message, SendPort replyTo) {
+ ReceivePort port = new ReceivePort();
+ replyTo.send(port.sendPort);
+ port.first.then((List<int> message) {
print("Log $message");
Expect.equals(5, message.length);
Expect.equals(0, message[0]);
@@ -20,18 +23,25 @@ void logMessages() {
Expect.equals(3, message[3]);
Expect.equals(4, message[4]);
port.close();
- replyTo.send(1, null);
+ replyTo.send(1);
print("Stopping log server.");
});
}
main() {
- SendPort remote = spawnFunction(logMessages);
+ ReceivePort receivePort = new ReceivePort();
+ Future<Isolate> remote = Isolate.spawn(logMessages, receivePort.sendPort);
List<int> msg = new List<int>(5);
for (int i = 0; i < 5; i++) {
msg[i] = i;
}
- remote.call(msg).then((int message) {
- Expect.equals(1, message);
+ StreamIterator iterator = new StreamIterator(receivePort);
+ iterator.moveNext().then((b) {
+ SendPort sendPort = iterator.current;
+ sendPort.send(msg);
+ return iterator.moveNext();
+ }).then((b) {
+ Expect.equals(1, iterator.current);
+ receivePort.close();
});
}
« no previous file with comments | « tests/isolate/unresolved_ports_test.dart ('k') | tests/lib/analyzer/analyze_tests.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698