OLD | NEW |
---|---|
(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 "dart:io"; | |
6 | |
7 void testFileExists() { | |
8 var tmp = new Directory("").createTempSync(); | |
9 var path = "${tmp.path}${Platform.pathSeparator}"; | |
10 | |
11 var file = new File("${path}myFile"); | |
12 file.createSync(); | |
13 | |
14 Expect.isTrue(new File(file.path).existsSync()); | |
15 Expect.isFalse(new Directory(file.path).existsSync()); | |
16 Expect.isFalse(new Link(file.path).existsSync()); | |
17 | |
18 file.deleteSync(); | |
19 Expect.isFalse(file.existsSync()); | |
20 | |
21 tmp.deleteSync(); | |
22 } | |
23 | |
24 void testDirectoryExists() { | |
25 var tmp = new Directory("").createTempSync(); | |
26 var path = "${tmp.path}${Platform.pathSeparator}"; | |
27 | |
28 var dir = new Directory("${path}myDirectory"); | |
29 dir.createSync(); | |
30 | |
31 Expect.isFalse(new File(dir.path).existsSync()); | |
32 Expect.isTrue(new Directory(dir.path).existsSync()); | |
33 Expect.isFalse(new Link(dir.path).existsSync()); | |
34 | |
35 dir.deleteSync(); | |
36 Expect.isFalse(dir.existsSync()); | |
37 | |
38 tmp.deleteSync(); | |
39 } | |
40 | |
41 void testFileLinkExists() { | |
42 var tmp = new Directory("").createTempSync(); | |
43 var path = "${tmp.path}${Platform.pathSeparator}"; | |
44 | |
45 var file = new File("${path}myFile"); | |
46 file.createSync(); | |
47 | |
48 var link = new Link("${path}myLink"); | |
49 link.createSync(file.path); | |
50 | |
51 Expect.isTrue(new File(link.path).existsSync()); | |
52 Expect.isFalse(new Directory(link.path).existsSync()); | |
53 Expect.isTrue(new Link(link.path).existsSync()); | |
54 | |
55 link.deleteSync(); | |
Søren Gjesse
2013/04/05 12:52:50
Add
Expect.isTrue(file.existsSync());
Expect.
Anders Johnsen
2013/04/08 06:50:49
This is already tested in broken-link test.
| |
56 Expect.isFalse(link.existsSync()); | |
57 | |
58 file.deleteSync(); | |
59 Expect.isFalse(file.existsSync()); | |
60 | |
61 tmp.deleteSync(); | |
62 } | |
63 | |
64 void testDirectoryLinkExists() { | |
65 var tmp = new Directory("").createTempSync(); | |
66 var path = "${tmp.path}${Platform.pathSeparator}"; | |
67 | |
68 var directory = new Directory("${path}myDirectory"); | |
69 directory.createSync(); | |
70 | |
71 var link = new Link("${path}myLink"); | |
72 link.createSync(directory.path); | |
73 | |
74 Expect.isFalse(new File(link.path).existsSync()); | |
75 Expect.isTrue(new Directory(link.path).existsSync()); | |
76 Expect.isTrue(new Link(link.path).existsSync()); | |
77 | |
78 link.deleteSync(); | |
Søren Gjesse
2013/04/05 12:52:50
Ditto.
Anders Johnsen
2013/04/08 06:50:49
Same.
| |
79 Expect.isFalse(link.existsSync()); | |
80 | |
81 directory.deleteSync(); | |
82 Expect.isFalse(directory.existsSync()); | |
83 | |
84 tmp.deleteSync(); | |
85 } | |
86 | |
87 void testBrokenLinkExists() { | |
88 var tmp = new Directory("").createTempSync(); | |
89 var path = "${tmp.path}${Platform.pathSeparator}"; | |
90 | |
91 var directory = new Directory("${path}myDirectory"); | |
92 directory.createSync(); | |
93 | |
94 var link = new Link("${path}myLink"); | |
95 link.createSync(directory.path); | |
96 directory.deleteSync(); | |
97 | |
98 Expect.isFalse(new File(link.path).existsSync()); | |
99 Expect.isFalse(new Directory(link.path).existsSync()); | |
100 Expect.isTrue(new Link(link.path).existsSync()); | |
101 | |
102 link.deleteSync(); | |
103 Expect.isFalse(link.existsSync()); | |
104 | |
105 tmp.deleteSync(); | |
106 } | |
107 | |
108 void main() { | |
109 testFileExists(); | |
110 testDirectoryExists(); | |
111 // Not available on Windows. | |
112 // testFileLinkExists(); | |
113 testDirectoryLinkExists(); | |
114 testBrokenLinkExists(); | |
115 } | |
116 | |
OLD | NEW |