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

Unified Diff: tests/isolate/illegal_msg_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/illegal_msg_stream_test.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/illegal_msg_test.dart
diff --git a/tests/isolate/illegal_msg_test.dart b/tests/isolate/illegal_msg_test.dart
index ed29bd974724a70d424a8c6752fb1a1f4c97844f..422ae39a55d48705ccbd60a907810e77363a62ab 100644
--- a/tests/isolate/illegal_msg_test.dart
+++ b/tests/isolate/illegal_msg_test.dart
@@ -9,29 +9,37 @@ import "package:async_helper/async_helper.dart";
funcFoo(x) => x + 2;
-echo() {
- port.receive((msg, reply) {
- reply.send("echoing ${msg(1)}}");
+echo(sendPort) {
+ var port = new ReceivePort();
+ sendPort.send(port.sendPort);
+ port.listen((msg) {
+ sendPort.send("echoing ${msg(1)}}");
});
}
main() {
- var snd = spawnFunction(echo);
+ ReceivePort port = new ReceivePort();
+ Future spawn = Isolate.spawn(echo, port.sendPort);
var caught_exception = false;
- try {
- snd.send(funcFoo, port.toSendPort());
- } catch (e) {
- caught_exception = true;
- }
+ var stream = port.asBroadcastStream();
+ asyncStart();
+ stream.first.then((snd) {
+ try {
+ snd.send(funcFoo);
+ } catch (e) {
+ caught_exception = true;
+ }
- if (caught_exception) {
- port.close();
- } else {
- asyncStart();
- port.receive((msg, reply) {
- print("from worker ${msg}");
- asyncEnd();
- });
- }
- Expect.isTrue(caught_exception);
+ if (caught_exception) {
+ port.close();
+ } else {
+ asyncStart();
+ stream.first.then((msg) {
+ print("from worker ${msg}");
+ asyncEnd();
+ });
+ }
+ Expect.isTrue(caught_exception);
+ asyncEnd();
+ });
}
« no previous file with comments | « tests/isolate/illegal_msg_stream_test.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698