OLD | NEW |
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. | 5 // Directory listing test. |
6 | 6 |
7 | 7 |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
(...skipping 13 matching lines...) Expand all Loading... |
24 Expect.isTrue(new File("333").existsSync()); | 24 Expect.isTrue(new File("333").existsSync()); |
25 Expect.isTrue(new File("../111").existsSync()); | 25 Expect.isTrue(new File("../111").existsSync()); |
26 Directory.current = ".."; | 26 Directory.current = ".."; |
27 Expect.isTrue(new File("111").existsSync()); | 27 Expect.isTrue(new File("111").existsSync()); |
28 Expect.isTrue(new File("222/333").existsSync()); | 28 Expect.isTrue(new File("222/333").existsSync()); |
29 // Deleting the current working directory causes an error. | 29 // Deleting the current working directory causes an error. |
30 // On Windows, the deletion fails, and on non-Windows, the getter fails. | 30 // On Windows, the deletion fails, and on non-Windows, the getter fails. |
31 Expect.throws(() { | 31 Expect.throws(() { |
32 temp.deleteSync(recursive: true); | 32 temp.deleteSync(recursive: true); |
33 Directory.current; | 33 Directory.current; |
34 }, (e) => e is DirectoryException); | 34 }, (e) => e is FileSystemException); |
35 Directory.current = initialCurrent; | 35 Directory.current = initialCurrent; |
36 Directory.current; | 36 Directory.current; |
37 if (temp.existsSync()) temp.deleteSync(recursive: true); | 37 if (temp.existsSync()) temp.deleteSync(recursive: true); |
38 asyncEnd(); | 38 asyncEnd(); |
39 }); | 39 }); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 testChangeDirectoryIllegalArguments() { | 43 testChangeDirectoryIllegalArguments() { |
44 Expect.throws(() => Directory.current = 1, (e) => e is ArgumentError); | 44 Expect.throws(() => Directory.current = 1, (e) => e is ArgumentError); |
45 Expect.throws(() => Directory.current = 111111111111111111111111111111111111, | 45 Expect.throws(() => Directory.current = 111111111111111111111111111111111111, |
46 (e) => e is ArgumentError); | 46 (e) => e is ArgumentError); |
47 Expect.throws(() => Directory.current = true, (e) => e is ArgumentError); | 47 Expect.throws(() => Directory.current = true, (e) => e is ArgumentError); |
48 Expect.throws(() => Directory.current = [], (e) => e is ArgumentError); | 48 Expect.throws(() => Directory.current = [], (e) => e is ArgumentError); |
49 Expect.throws(() => Directory.current = new File("xxx"), | 49 Expect.throws(() => Directory.current = new File("xxx"), |
50 (e) => e is ArgumentError); | 50 (e) => e is ArgumentError); |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 main() { | 54 main() { |
55 testChangeDirectory(); | 55 testChangeDirectory(); |
56 testChangeDirectoryIllegalArguments(); | 56 testChangeDirectoryIllegalArguments(); |
57 } | 57 } |
OLD | NEW |