| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_unhandled_exception_uri_helper; | 5 library isolate_unhandled_exception_uri_helper; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | |
| 8 import 'dart:async'; | 7 import 'dart:async'; |
| 9 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 10 | 9 |
| 11 // Tests that isolate code in another script keeps message handling working | 10 // Tests that isolate code in another script keeps message handling working |
| 12 // after throwing an unhandled exception, if it has a function called | 11 // after throwing an unhandled exception, if it has a function called |
| 13 // unhandledExceptionCallback that returns true (continue handling). | 12 // unhandledExceptionCallback that returns true (continue handling). |
| 14 | 13 |
| 15 // Note: this test will hang if an uncaught exception isn't handled, | 14 // Note: this test will hang if an uncaught exception isn't handled, |
| 16 // either by an error in the callback or it returning false. | 15 // either by an error in the callback or it returning false. |
| 17 | 16 |
| 18 void main() { | 17 void main() { |
| 19 var isolate_port = spawnUri('isolate_unhandled_exception_uri_helper.dart'); | 18 var isolate_port = spawnUri('isolate_unhandled_exception_uri_helper.dart'); |
| 20 | 19 |
| 21 // Send a message that will cause an ignorable exception to be thrown. | 20 // Send a message that will cause an ignorable exception to be thrown. |
| 22 Future f = isolate_port.call('throw exception'); | 21 Future f = isolate_port.call('throw exception'); |
| 23 f.catchError((error) { | 22 f.catchError((error) { |
| 24 Expect.fail("Error not expected"); | 23 Expect.fail("Error not expected"); |
| 25 }); | 24 }); |
| 26 | 25 |
| 27 // Verify that isolate can still handle messages. | 26 // Verify that isolate can still handle messages. |
| 28 isolate_port.call('hi').then((value) { | 27 isolate_port.call('hi').then((value) { |
| 29 Expect.equals('hello', value); | 28 Expect.equals('hello', value); |
| 30 }, onError: (error) { | 29 }, onError: (error) { |
| 31 Expect.fail("Error not expected"); | 30 Expect.fail("Error not expected"); |
| 32 }); | 31 }); |
| 33 | 32 |
| 34 } | 33 } |
| OLD | NEW |