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/standalone/io/directory_list_nonexistent_test.dart

Issue 16123036: Clean up dart:io exceptions. (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
« no previous file with comments | « tests/standalone/io/directory_error_test.dart ('k') | tests/standalone/io/directory_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 // Directory listing test that tests listSync on a missing directory. 5 // Directory listing test that tests listSync on a missing directory.
6 // 6 //
7 // TODO(7157): Merge this test into directory_test.dart testListNonExistent() 7 // TODO(7157): Merge this test into directory_test.dart testListNonExistent()
8 // when it no longer crashes on Windows, when issue 7157 is resolved. 8 // when it no longer crashes on Windows, when issue 7157 is resolved.
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:io"; 11 import "dart:io";
12 import "dart:isolate"; 12 import "dart:isolate";
13 13
14 void testListNonExistent() { 14 void testListNonExistent() {
15 var keepAlive = new ReceivePort(); 15 var keepAlive = new ReceivePort();
16 new Directory("").createTemp().then((d) { 16 new Directory("").createTemp().then((d) {
17 d.delete().then((ignore) { 17 d.delete().then((ignore) {
18 Expect.throws(() => d.listSync(), (e) => e is DirectoryIOException); 18 Expect.throws(() => d.listSync(), (e) => e is DirectoryException);
19 Expect.throws(() => d.listSync(recursive: true), 19 Expect.throws(() => d.listSync(recursive: true),
20 (e) => e is DirectoryIOException); 20 (e) => e is DirectoryException);
21 keepAlive.close(); 21 keepAlive.close();
22 }); 22 });
23 }); 23 });
24 } 24 }
25 25
26 void testListTooLongName() { 26 void testListTooLongName() {
27 var keepAlive = new ReceivePort(); 27 var keepAlive = new ReceivePort();
28 new Directory("").createTemp().then((d) { 28 new Directory("").createTemp().then((d) {
29 var subDirName = 'subdir'; 29 var subDirName = 'subdir';
30 var subDir = new Directory("${d.path}/$subDirName"); 30 var subDir = new Directory("${d.path}/$subDirName");
31 subDir.create().then((ignore) { 31 subDir.create().then((ignore) {
32 // Construct a long string of the form 32 // Construct a long string of the form
33 // 'tempdir/subdir/../subdir/../subdir'. 33 // 'tempdir/subdir/../subdir/../subdir'.
34 var buffer = new StringBuffer(); 34 var buffer = new StringBuffer();
35 buffer.write(subDir.path); 35 buffer.write(subDir.path);
36 for (var i = 0; i < 1000; i++) { 36 for (var i = 0; i < 1000; i++) {
37 buffer.write("/../${subDirName}"); 37 buffer.write("/../${subDirName}");
38 } 38 }
39 var long = new Directory("${buffer.toString()}"); 39 var long = new Directory("${buffer.toString()}");
40 Expect.throws(() => long.listSync(), 40 Expect.throws(() => long.listSync(),
41 (e) => e is DirectoryIOException); 41 (e) => e is DirectoryException);
42 Expect.throws(() => long.listSync(recursive: true), 42 Expect.throws(() => long.listSync(recursive: true),
43 (e) => e is DirectoryIOException); 43 (e) => e is DirectoryException);
44 d.deleteSync(recursive: true); 44 d.deleteSync(recursive: true);
45 keepAlive.close(); 45 keepAlive.close();
46 }); 46 });
47 }); 47 });
48 } 48 }
49 49
50 void main() { 50 void main() {
51 testListNonExistent(); 51 testListNonExistent();
52 testListTooLongName(); 52 testListTooLongName();
53 } 53 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_error_test.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698