| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:async'; |
| 6 import 'dart:isolate'; |
| 7 |
| 8 runTest() { |
| 9 IsolateSink mainIsolate; |
| 10 stream.listen((msg) { |
| 11 mainIsolate = msg; |
| 12 throw new RuntimeError("ignore exception"); |
| 13 }, onDone: () { |
| 14 mainIsolate.add("received done"); |
| 15 mainIsolate.close(); |
| 16 }); |
| 17 } |
| 18 |
| 19 bool globalErrorHandler(IsolateUnhandledException e) { |
| 20 var source = e.source; |
| 21 if (source is AsyncError) { |
| 22 source = source.error; |
| 23 } |
| 24 return source is RuntimeError && source.message == "ignore exception"; |
| 25 } |
| 26 |
| 27 main() { |
| 28 // Make sure this test doesn't last longer than 2 seconds. |
| 29 var timer = new Timer(const Duration(seconds: 2), () { throw "failed"; }); |
| 30 |
| 31 var box = new MessageBox(); |
| 32 IsolateSink otherIsolate = streamSpawnFunction(runTest, globalErrorHandler); |
| 33 otherIsolate.add(box.sink); |
| 34 otherIsolate.close(); |
| 35 box.stream.single.then((msg) { |
| 36 Expect.equals("received done", msg); |
| 37 timer.cancel(); |
| 38 }); |
| 39 } |
| OLD | NEW |