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 import "dart:isolate"; | 5 import "dart:isolate"; |
6 import "dart:async"; | 6 import "dart:async"; |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
9 | 9 |
10 void toplevel(port, message) { port.send("toplevel:$message"); } | 10 void toplevel(port, message) { port.send("toplevel:$message"); } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 void testUnsendable(name, func) { | 146 void testUnsendable(name, func) { |
147 asyncStart(); | 147 asyncStart(); |
148 Isolate.spawn(nop, func).then((v) => throw "allowed spawn direct?", | 148 Isolate.spawn(nop, func).then((v) => throw "allowed spawn direct?", |
149 onError: (e,s){ asyncEnd(); }); | 149 onError: (e,s){ asyncEnd(); }); |
150 asyncStart(); | 150 asyncStart(); |
151 Isolate.spawn(nop, [func]).then((v) => throw "allowed spawn wrapped?", | 151 Isolate.spawn(nop, [func]).then((v) => throw "allowed spawn wrapped?", |
152 onError: (e,s){ asyncEnd(); }); | 152 onError: (e,s){ asyncEnd(); }); |
153 | 153 |
154 asyncStart(); | 154 asyncStart(); |
155 var noReply = new RawReceivePort((_) { throw "Unexpected message: $_"; }); | 155 var noReply = new RawReceivePort((_) { throw "Unexpected message: $_"; }); |
156 // Currently succeedes incorrectly in dart2js. | 156 Expect.throws(() { |
157 Expect.throws(() { /// 01: ok | 157 noReply.sendPort.send(func); |
158 noReply.sendPort.send(func); /// 01: continued | 158 }, null, "send direct"); |
159 }, null, "send direct"); /// 01: continued | 159 Expect.throws(() { |
160 Expect.throws(() { /// 01: continued | 160 noReply.sendPort.send([func]); |
161 noReply.sendPort.send([func]); /// 01: continued | 161 }, null, "send wrapped"); |
162 }, null, "send wrapped"); /// 01: continued | |
163 scheduleMicrotask(() { | 162 scheduleMicrotask(() { |
164 noReply.close(); | 163 noReply.close(); |
165 asyncEnd(); | 164 asyncEnd(); |
166 }); | 165 }); |
167 | 166 |
168 // Try sending through other isolate. | 167 // Try sending through other isolate. |
169 asyncStart(); | 168 asyncStart(); |
170 echoPort((v) { Expect.equals(0, v); }) | 169 echoPort((v) { Expect.equals(0, v); }) |
171 .then((p) { | 170 .then((p) { |
172 try { | 171 try { |
173 p.send(func); | 172 p.send(func); |
174 } finally { | 173 } finally { |
175 p.send(0); // Closes echo port. | 174 p.send(0); // Closes echo port. |
176 } | 175 } |
177 }) | 176 }) |
178 .then((p) => throw "unreachable 2", | 177 .then((p) => throw "unreachable 2", |
179 onError: (e, s) {asyncEnd();}); | 178 onError: (e, s) {asyncEnd();}); |
180 } | 179 } |
181 | 180 |
182 void nop(_) {} | 181 void nop(_) {} |
183 | 182 |
184 void callFunc(message) { | 183 void callFunc(message) { |
185 message[0](message[1], message[2]); | 184 message[0](message[1], message[2]); |
186 } | 185 } |
OLD | NEW |