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

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

Issue 16154017: Rename RuntimeError to CyclicIntializationError, as per spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 library test; 5 library test;
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 10
11 runTest() { 11 runTest() {
12 IsolateSink mainIsolate; 12 IsolateSink mainIsolate;
13 stream.listen((msg) { 13 stream.listen((msg) {
14 mainIsolate = msg; 14 mainIsolate = msg;
15 throw new RuntimeError("ignore exception"); 15 throw new UnsupportedError("ignore exception");
16 }, onDone: () { 16 }, onDone: () {
17 mainIsolate.add("received done"); 17 mainIsolate.add("received done");
18 mainIsolate.close(); 18 mainIsolate.close();
19 }); 19 });
20 } 20 }
21 21
22 bool globalErrorHandler(IsolateUnhandledException e) { 22 bool globalErrorHandler(IsolateUnhandledException e) {
23 var source = e.source; 23 var source = e.source;
24 return source is RuntimeError && source.message == "ignore exception"; 24 return source is UnsupportedError && source.message == "ignore exception";
25 } 25 }
26 26
27 main() { 27 main() {
28 var keepRunningBox = new MessageBox(); 28 var keepRunningBox = new MessageBox();
29 // Make sure this test doesn't last longer than 2 seconds. 29 // Make sure this test doesn't last longer than 2 seconds.
30 var timer = new Timer(const Duration(seconds: 2), () { throw "failed"; }); 30 var timer = new Timer(const Duration(seconds: 2), () { throw "failed"; });
31 31
32 var box = new MessageBox(); 32 var box = new MessageBox();
33 IsolateSink otherIsolate = streamSpawnFunction(runTest, globalErrorHandler); 33 IsolateSink otherIsolate = streamSpawnFunction(runTest, globalErrorHandler);
34 otherIsolate.add(box.sink); 34 otherIsolate.add(box.sink);
35 // The previous event should have been handled entirely, but the current 35 // The previous event should have been handled entirely, but the current
36 // implementations don't guarantee that and might mix the done event with 36 // implementations don't guarantee that and might mix the done event with
37 // the handling of the previous event. We therefore delay the closing. 37 // the handling of the previous event. We therefore delay the closing.
38 // Note: if the done is sent too early it won't lead to failing tests, but 38 // Note: if the done is sent too early it won't lead to failing tests, but
39 // just won't make sure that the globalErrorHandler works. 39 // just won't make sure that the globalErrorHandler works.
40 new Timer(const Duration(milliseconds: 10), otherIsolate.close); 40 new Timer(const Duration(milliseconds: 10), otherIsolate.close);
41 box.stream.single.then((msg) { 41 box.stream.single.then((msg) {
42 Expect.equals("received done", msg); 42 Expect.equals("received done", msg);
43 timer.cancel(); 43 timer.cancel();
44 keepRunningBox.stream.close(); 44 keepRunningBox.stream.close();
45 }); 45 });
46 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698