| Index: tests/isolate/kill_self_test.dart
|
| diff --git a/tests/isolate/ping_pause_test.dart b/tests/isolate/kill_self_test.dart
|
| similarity index 50%
|
| copy from tests/isolate/ping_pause_test.dart
|
| copy to tests/isolate/kill_self_test.dart
|
| index 11fa951f0af29a4ba4ac2dba37ffd4eab5a0f3e5..932dca6fb38d9a1e62cddf82bfcf9dc6ff25812a 100644
|
| --- a/tests/isolate/ping_pause_test.dart
|
| +++ b/tests/isolate/kill_self_test.dart
|
| @@ -9,9 +9,17 @@ import "package:async_helper/async_helper.dart";
|
|
|
| isomain1(replyPort) {
|
| RawReceivePort port = new RawReceivePort();
|
| + bool firstEvent = true;
|
| port.handler = (v) {
|
| - replyPort.send(v);
|
| - if (v == 0) port.close();
|
| + if (!firstEvent) {
|
| + throw "Survived suicide";
|
| + }
|
| + var controlPort = v[0];
|
| + var killCapability = v[1];
|
| + firstEvent = false;
|
| + var isolate = new Isolate(controlPort,
|
| + terminateCapability: killCapability);
|
| + isolate.kill(Isolate.IMMEDIATE);
|
| };
|
| replyPort.send(port.sendPort);
|
| }
|
| @@ -21,29 +29,15 @@ void main() {
|
| var completer = new Completer(); // Completed by first reply from isolate.
|
| RawReceivePort reply = new RawReceivePort(completer.complete);
|
| Isolate.spawn(isomain1, reply.sendPort).then((Isolate isolate) {
|
| - List result = [];
|
| - completer.future.then((echoPort) {
|
| - reply.handler = (v) {
|
| - result.add(v);
|
| - if (v == 0) {
|
| - Expect.listEquals([4, 3, 2, 1, 0], result);
|
| - reply.close();
|
| - asyncEnd();
|
| - }
|
| - };
|
| - echoPort.send(4);
|
| - echoPort.send(3);
|
| - Capability resume = isolate.pause();
|
| - var pingPort = new RawReceivePort();
|
| - pingPort.handler = (_) {
|
| - Expect.isTrue(result.length <= 2);
|
| - echoPort.send(0);
|
| - isolate.resume(resume);
|
| - pingPort.close();
|
| - };
|
| - isolate.ping(pingPort.sendPort, Isolate.PING_CONTROL);
|
| - echoPort.send(2);
|
| - echoPort.send(1);
|
| + completer.future.then((isolatePort) {
|
| + RawReceivePort exitSignal;
|
| + exitSignal = new RawReceivePort((_) {
|
| + exitSignal.close();
|
| + asyncEnd();
|
| + });
|
| + isolate.addOnExitListener(exitSignal.sendPort);
|
| + isolatePort.send([isolate.controlPort, isolate.terminateCapability]);
|
| + reply.close();
|
| });
|
| });
|
| }
|
|
|