| Index: tests/isolate/global_error_handler2_test.dart
|
| diff --git a/tests/lib/async/run_async4_test.dart b/tests/isolate/global_error_handler2_test.dart
|
| similarity index 50%
|
| copy from tests/lib/async/run_async4_test.dart
|
| copy to tests/isolate/global_error_handler2_test.dart
|
| index 46967dfcf1ec9b15556cd4c3c84e62569eccd2c2..014dcffd068561deb198e7be93f014db8b9f1fe3 100644
|
| --- a/tests/lib/async/run_async4_test.dart
|
| +++ b/tests/isolate/global_error_handler2_test.dart
|
| @@ -2,25 +2,21 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -library run_async_test;
|
| -
|
| import 'dart:async';
|
| import 'dart:isolate';
|
|
|
| -void startTest(SendPort finishPort, replyPort) {
|
| - int invokedCallbacks = 0;
|
| -
|
| - for (int i = 0; i < 100; i++) {
|
| - runAsync(() {
|
| - invokedCallbacks++;
|
| - if (invokedCallbacks == 100) finishPort.send("done");
|
| - if (i == 50) throw new RuntimeError("ignore exception");
|
| - });
|
| - }
|
| -}
|
| -
|
| runTest() {
|
| - port.receive(startTest);
|
| + SendPort mainIsolate;
|
| + bool isFirst = true;
|
| + port.receive((msg, replyTo) {
|
| + if (isFirst) {
|
| + mainIsolate = msg;
|
| + isFirst = false;
|
| + throw new RuntimeError("ignore exception");
|
| + }
|
| + Expect.equals("message 2", msg);
|
| + mainIsolate.send("received");
|
| + });
|
| }
|
|
|
| bool globalErrorHandler(IsolateUnhandledException e) {
|
| @@ -28,10 +24,16 @@ bool globalErrorHandler(IsolateUnhandledException e) {
|
| }
|
|
|
| main() {
|
| + // Make sure this test doesn't last longer than 2 seconds.
|
| + var timer = new Timer(const Duration(seconds: 2), () { throw "failed"; });
|
| +
|
| var port = new ReceivePort();
|
| - var timer;
|
| SendPort otherIsolate = spawnFunction(runTest, globalErrorHandler);
|
| otherIsolate.send(port.toSendPort());
|
| - port.receive((msg, replyPort) { port.close(); timer.cancel(); });
|
| - timer = new Timer(const Duration(seconds: 2), () { throw "failed"; });
|
| + otherIsolate.send("message 2");
|
| + port.receive((msg, replyPort) {
|
| + Expect.equals("received", msg);
|
| + port.close();
|
| + timer.cancel();
|
| + });
|
| }
|
|
|