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

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

Issue 12919011: Remove streamSpawnUri and mangler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 9 months 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 var firstFunction; 8 var firstFunction;
9 var finishFunction; 9 var finishFunction;
10 10
11 void runFunctions() { 11 void runFunctions() {
12 try { 12 try {
13 firstFunction(); 13 firstFunction();
14 } catch (e) { 14 } catch (e) {
15 new Timer(Duration.ZERO, finishFunction); 15 new Timer(Duration.ZERO, finishFunction);
16 throw; 16 throw;
17 } 17 }
18 } 18 }
19 19
20 void startTest(SendPort finishPort, replyPort) { 20 void startTest(StreamSink finishSink) {
21 firstFunction = () { throw new RuntimeError("ignore exception"); }; 21 firstFunction = () { throw new RuntimeError("ignore exception"); };
22 finishFunction = () { finishPort.send("done"); }; 22 finishFunction = () { finishSink.add("done"); finishPort.close(); };
23 new Timer(Duration.ZERO, runFunctions); 23 new Timer(Duration.ZERO, runFunctions);
24 } 24 }
25 25
26 runTest() { 26 runTest() {
27 port.receive(startTest); 27 stream.single.then(startTest);
28 } 28 }
29 29
30 bool globalErrorHandler(IsolateUnhandledException e) { 30 bool globalErrorHandler(IsolateUnhandledException e) {
31 return e.source is RuntimeError && e.source.message == "ignore exception"; 31 return e.source is RuntimeError && e.source.message == "ignore exception";
32 } 32 }
33 33
34 main() { 34 main() {
35 var port = new ReceivePort(); 35 var box = new MessageBox();
36 var timer; 36 var timer;
37 SendPort otherIsolate = spawnFunction(runTest, globalErrorHandler); 37 StreamSink otherIsolate = streamSpawnFunction(runTest, globalErrorHandler);
38 otherIsolate.send(port.toSendPort()); 38 otherIsolate.add(box.sink);
39 port.receive((msg, replyPort) { port.close(); timer.cancel(); }); 39 otherIsolate.close();
40 box.stream.single.then((msg) {
41 box.stream.close();
42 timer.cancel();
43 });
40 timer = new Timer(const Duration(seconds: 2), () { throw "failed"; }); 44 timer = new Timer(const Duration(seconds: 2), () { throw "failed"; });
41 } 45 }
OLDNEW
« no previous file with comments | « tests/isolate/global_error_handler_stream2_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