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

Side by Side Diff: tests/standalone/io/async_catch_errors_test.dart

Issue 18788002: Let completers complete in the zone they were constructed in. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move comment to correct place. Created 7 years, 5 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
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import "package:expect/expect.dart";
6 import 'dart:async';
7 import 'dart:isolate';
8 import 'dart:io';
9
10 var events = [];
11
12 void testSocketException() {
13 var completer = new Completer();
14 runZonedExperimental(() {
15 Socket.connect("4", 1).then((Socket s) {
16 Expect.fail("Socket should not be able to connect");
17 });
18 }, onError: (err) {
19 if (err is! SocketException) Expect.fail("Not expected error: $err");
20 completer.complete("socket test, ok.");
21 events.add("SocketException");
22 });
23 return completer.future;
24 }
25
26 void testFileException() {
27 var completer = new Completer();
28 runZonedExperimental(() {
29 new File("lol it's not a file\n").openRead().listen(null);
30 }, onError: (err) {
31 if (err is! FileException) Expect.fail("Not expected error: $err");
32 completer.complete("file test, ok.");
33 events.add("FileException");
34 });
35 return completer.future;
36 }
37
38 main() {
39 // We keep a ReceivePort open until all tests are done. This way the VM will
40 // hang if the callbacks are not invoked and the test will time out.
41 var timeOutPort = new ReceivePort();
42 testSocketException()
43 .then((_) => testFileException())
44 .then((_) {
45 timeOutPort.close();
46 Expect.listEquals(["SocketException", "FileException"],
47 events);
48 });
49 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698