| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library isolate_current_test; | 5 library isolate_current_test; |
| 6 |
| 6 import "dart:isolate"; | 7 import "dart:isolate"; |
| 7 import "dart:async"; | 8 import "dart:async"; |
| 8 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 9 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| 10 | 11 |
| 11 void main() { | 12 void main() { |
| 12 asyncStart(); | 13 asyncStart(); |
| 13 | 14 |
| 14 Expect.isNotNull(Isolate.current); | 15 Expect.isNotNull(Isolate.current); |
| 15 | 16 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Isolate isolate2 = transform(isoData); | 112 Isolate isolate2 = transform(isoData); |
| 112 port.close(); | 113 port.close(); |
| 113 Isolate isolate = Isolate.current; | 114 Isolate isolate = Isolate.current; |
| 114 expectIsolateEquals(isolate, isolate2); | 115 expectIsolateEquals(isolate, isolate2); |
| 115 responsePort.send(true); | 116 responsePort.send(true); |
| 116 }; | 117 }; |
| 117 responsePort.send(port.sendPort); | 118 responsePort.send(port.sendPort); |
| 118 } | 119 } |
| 119 | 120 |
| 120 /** Convert isolate to list (of control port and capabilities). */ | 121 /** Convert isolate to list (of control port and capabilities). */ |
| 121 i2l(Isolate isolate) => [isolate.controlPort, | 122 i2l(Isolate isolate) => |
| 122 isolate.pauseCapability, | 123 [isolate.controlPort, isolate.pauseCapability, isolate.terminateCapability]; |
| 123 isolate.terminateCapability]; | |
| 124 /** Convert list to isolate. */ | 124 /** Convert list to isolate. */ |
| 125 l2i(List list) => new Isolate(list[0], pauseCapability: list[1], | 125 l2i(List list) => new Isolate(list[0], |
| 126 terminateCapability: list[2]); | 126 pauseCapability: list[1], terminateCapability: list[2]); |
| 127 | 127 |
| 128 /** Identity transformation. */ | 128 /** Identity transformation. */ |
| 129 id(Isolate isolate) => isolate; | 129 id(Isolate isolate) => isolate; |
| 130 | 130 |
| 131 void expectIsolateEquals(Isolate expect, Isolate actual) { | 131 void expectIsolateEquals(Isolate expect, Isolate actual) { |
| 132 Expect.equals(expect.controlPort, actual.controlPort); | 132 Expect.equals(expect.controlPort, actual.controlPort); |
| 133 Expect.equals(expect.pauseCapability, actual.pauseCapability); | 133 Expect.equals(expect.pauseCapability, actual.pauseCapability); |
| 134 Expect.equals(expect.terminateCapability, actual.terminateCapability); | 134 Expect.equals(expect.terminateCapability, actual.terminateCapability); |
| 135 } | 135 } |
| OLD | NEW |