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_test; | 5 library isolate_unhandled_exception_test; |
6 | 6 |
7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
8 | 8 |
9 // Tests that an isolate's keeps message handling working after | 9 // Tests that an isolate's keeps message handling working after |
10 // throwing an unhandled exception, if it was created with an | 10 // throwing an unhandled exception, if it was created with an |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 bool exceptionCallback(IsolateUnhandledException e) { | 29 bool exceptionCallback(IsolateUnhandledException e) { |
30 return e.source.message == 'ignore this exception'; | 30 return e.source.message == 'ignore this exception'; |
31 } | 31 } |
32 | 32 |
33 void main() { | 33 void main() { |
34 var isolate_port = spawnFunction(entry, exceptionCallback); | 34 var isolate_port = spawnFunction(entry, exceptionCallback); |
35 | 35 |
36 // Send a message that will cause an ignorable exception to be thrown. | 36 // Send a message that will cause an ignorable exception to be thrown. |
37 Future f = isolate_port.call('throw exception'); | 37 Future f = isolate_port.call('throw exception'); |
38 f.onComplete((future) { | 38 f.catchError((error) { |
39 // Exception wasn't ignored as it was supposed to be. | 39 // Exception wasn't ignored as it was supposed to be. |
40 Expect.equals(null, future.exception); | 40 Expect.fail("Error not expected"); |
41 }); | 41 }); |
42 | 42 |
43 // Verify that isolate can still handle messages. | 43 // Verify that isolate can still handle messages. |
44 isolate_port.call('hi').onComplete((future) { | 44 isolate_port.call('hi').then((value) { |
45 Expect.equals(null, future.exception); | 45 Expect.equals('hello', value); |
46 Expect.equals('hello', future.value); | 46 }, onError: (error) { |
| 47 Expect.fail("Error not expected"); |
47 }); | 48 }); |
48 } | 49 } |
OLD | NEW |