Index: tests/isolate/ondone_test.dart |
diff --git a/tests/isolate/ondone_test.dart b/tests/isolate/ondone_test.dart |
index af990ad31e8e3d05cd950bcbe23519efadfed95e..ec0007cab06d4026e2b204f47f455e577654a8f6 100644 |
--- a/tests/isolate/ondone_test.dart |
+++ b/tests/isolate/ondone_test.dart |
@@ -23,6 +23,7 @@ void isomain(SendPort replyPort) { |
void main() { |
testExit(); |
testCancelExit(); |
+ testOverrideResponse(); |
} |
void testExit() { |
@@ -31,14 +32,15 @@ void testExit() { |
var completer = new Completer(); // Completed by first reply from isolate. |
RawReceivePort reply = new RawReceivePort(completer.complete); |
RawReceivePort onExitPort; |
- onExitPort = new RawReceivePort((_) { |
+ onExitPort = new RawReceivePort((v) { |
+ if (v != "RESPONSE") throw "WRONG RESPONSE: $v"; |
reply.close(); |
onExitPort.close(); |
if (!mayComplete) throw "COMPLETED EARLY"; |
asyncEnd(); |
}); |
Isolate.spawn(isomain, reply.sendPort).then((Isolate isolate) { |
- isolate.addOnExitListener(onExitPort.sendPort); |
+ isolate.addOnExitListener(onExitPort.sendPort, response: "RESPONSE"); |
return completer.future; |
}).then((echoPort) { |
int counter = 4; |
@@ -92,3 +94,33 @@ void testCancelExit() { |
}); |
}); |
} |
+ |
+void testOverrideResponse() { |
+ bool mayComplete = false; |
+ asyncStart(); |
+ var completer = new Completer(); // Completed by first reply from isolate. |
+ RawReceivePort reply = new RawReceivePort(completer.complete); |
+ RawReceivePort onExitPort; |
+ onExitPort = new RawReceivePort((v) { |
+ if (v != "RESPONSE2") throw "WRONG RESPONSE: $v"; |
+ reply.close(); |
+ onExitPort.close(); |
+ if (!mayComplete) throw "COMPLETED EARLY"; |
+ asyncEnd(); |
+ }); |
+ Isolate.spawn(isomain, reply.sendPort).then((Isolate isolate) { |
+ isolate.addOnExitListener(onExitPort.sendPort, response: "RESPONSE"); |
+ isolate.addOnExitListener(onExitPort.sendPort, response: "RESPONSE2"); |
+ return completer.future; |
+ }).then((echoPort) { |
+ int counter = 4; |
+ reply.handler = (v) { |
+ if (v != counter) throw "WRONG REPLY"; |
+ if (v == 0) throw "REPLY INSTEAD OF SHUTDOWN"; |
+ counter--; |
+ mayComplete = (counter == 0); |
+ echoPort.send(counter); |
+ }; |
+ echoPort.send(counter); |
+ }); |
+} |