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(); |
}); |
} |