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

Side by Side Diff: tests/isolate/global_error_handler_test.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month 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
OLDNEW
(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 library test;
6
7 import 'dart:async';
8 import 'dart:isolate';
9
10 var firstFunction;
11 var finishFunction;
12
13 void runFunctions() {
14 try {
15 firstFunction();
16 } catch (e) {
17 new Timer(Duration.ZERO, finishFunction);
18 rethrow;
19 }
20 }
21
22 void startTest(SendPort finishPort, replyPort) {
23 firstFunction = () { throw new UnsupportedError("ignore exception"); };
24 finishFunction = () { finishPort.send("done"); };
25 new Timer(Duration.ZERO, runFunctions);
26 }
27
28 runTest() {
29 port.receive(startTest);
30 }
31
32 bool globalErrorHandler(IsolateUnhandledException e) {
33 return e.source is UnsupportedError && e.source.message == "ignore exception";
34 }
35
36 main() {
37 var port = new ReceivePort();
38 var timer;
39 SendPort otherIsolate = spawnFunction(runTest, globalErrorHandler);
40 otherIsolate.send(port.toSendPort());
41 port.receive((msg, replyPort) { port.close(); timer.cancel(); });
42 timer = new Timer(const Duration(seconds: 2), () { throw "failed"; });
43 }
OLDNEW
« no previous file with comments | « tests/isolate/global_error_handler_stream_test.dart ('k') | tests/isolate/illegal_msg_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698