Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: tests/vm/dart/isolate_unhandled_exception_test.dart

Issue 11596002: Changed the test a bit to ensure dart:io is not included as dartium cannot import dart:io (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/vm/dart/isolate_unhandled_exception_test2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:io';
9 8
10 // Tests that an isolate's keeps message handling working after 9 // Tests that an isolate's keeps message handling working after
11 // throwing an unhandled exception, if it was created with an 10 // throwing an unhandled exception, if it was created with an
12 // unhandled exception callback that returns true (continue handling). 11 // unhandled exception callback that returns true (continue handling).
13 // This test verifies that a callback function specified in 12 // This test verifies that a callback function specified in
14 // Isolate.spawnFunction is called. 13 // Isolate.spawnFunction is called.
15 14
16 // Note: this test will hang if an uncaught exception isn't handled, 15 // Note: this test will hang if an uncaught exception isn't handled,
17 // either by an error in the callback or it returning false. 16 // either by an error in the callback or it returning false.
18 17
19 void entry() { 18 void entry() {
20 port.receive((message, replyTo) { 19 port.receive((message, replyTo) {
21 if (message == 'throw exception') { 20 if (message == 'throw exception') {
21 replyTo.call('throwing exception');
22 throw new RuntimeError('ignore this exception'); 22 throw new RuntimeError('ignore this exception');
23 } 23 }
24 replyTo.call('hello'); 24 replyTo.call('hello');
25 port.close(); 25 port.close();
26 }); 26 });
27 } 27 }
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.onComplete((future) {
39 // Exception wasn't ignored as it was supposed to be. 39 // Exception wasn't ignored as it was supposed to be.
40 print('failed handling exception'); 40 Expect.equals(null, future.exception);
41 exit(1);
42 }); 41 });
43 42
44 // Verify that isolate can still handle messages. 43 // Verify that isolate can still handle messages.
45 isolate_port.call('hi').onComplete((future) { 44 isolate_port.call('hi').onComplete((future) {
46 if (future.exception != null) { 45 Expect.equals(null, future.exception);
47 print('unhandled exception: ${future.exception}'); 46 Expect.equals('hello', future.value);
48 exit(1);
49 }
50 if (future.value != 'hello') {
51 print('unexpected response: ${future.value}');
52 exit(1);
53 }
54 exit(0);
55 }); 47 });
56 } 48 }
OLDNEW
« no previous file with comments | « no previous file | tests/vm/dart/isolate_unhandled_exception_test2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698