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

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

Issue 26968003: Remove DirectoryException and LinkException from dart:io and use FileException instaed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge with master. 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
« no previous file with comments | « sdk/lib/io/link.dart ('k') | tests/standalone/io/directory_chdir_test.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) 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:io'; 6 import 'dart:io';
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
11 var events = []; 11 var events = [];
12 12
13 Future testSocketException() { 13 Future testSocketException() {
14 var completer = new Completer(); 14 var completer = new Completer();
15 runZoned(() { 15 runZoned(() {
16 Socket.connect("4", 1).then((Socket s) { 16 Socket.connect("4", 1).then((Socket s) {
17 Expect.fail("Socket should not be able to connect"); 17 Expect.fail("Socket should not be able to connect");
18 }); 18 });
19 }, onError: (err) { 19 }, onError: (err) {
20 if (err is! SocketException) Expect.fail("Not expected error: $err"); 20 if (err is! SocketException) Expect.fail("Not expected error: $err");
21 completer.complete("socket test, ok."); 21 completer.complete("socket test, ok.");
22 events.add("SocketException"); 22 events.add("SocketException");
23 }); 23 });
24 return completer.future; 24 return completer.future;
25 } 25 }
26 26
27 Future testFileException() { 27 Future testFileSystemException() {
28 var completer = new Completer(); 28 var completer = new Completer();
29 runZoned(() { 29 runZoned(() {
30 new File("lol it's not a file\n").openRead().listen(null); 30 new File("lol it's not a file\n").openRead().listen(null);
31 }, onError: (err) { 31 }, onError: (err) {
32 if (err is! FileException) Expect.fail("Not expected error: $err"); 32 if (err is! FileSystemException) Expect.fail("Not expected error: $err");
33 completer.complete("file test, ok."); 33 completer.complete("file test, ok.");
34 events.add("FileException"); 34 events.add("FileSystemException");
35 }); 35 });
36 return completer.future; 36 return completer.future;
37 } 37 }
38 38
39 main() { 39 main() {
40 // We keep a ReceivePort open until all tests are done. This way the VM will 40 // We keep a ReceivePort open until all tests are done. This way the VM will
41 // hang if the callbacks are not invoked and the test will time out. 41 // hang if the callbacks are not invoked and the test will time out.
42 asyncStart(); 42 asyncStart();
43 testSocketException() 43 testSocketException()
44 .then((_) => testFileException()) 44 .then((_) => testFileSystemException())
45 .then((_) { 45 .then((_) {
46 asyncEnd(); 46 asyncEnd();
47 Expect.listEquals(["SocketException", "FileException"], 47 Expect.listEquals(["SocketException", "FileSystemException"],
48 events); 48 events);
49 }); 49 });
50 } 50 }
OLDNEW
« no previous file with comments | « sdk/lib/io/link.dart ('k') | tests/standalone/io/directory_chdir_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698