Chromium Code Reviews| Index: tests/standalone/io/file_system_exists_test.dart |
| diff --git a/tests/standalone/io/file_system_exists_test.dart b/tests/standalone/io/file_system_exists_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bacd6c86d6a6e7c19e0f226fc5283b8c19829afc |
| --- /dev/null |
| +++ b/tests/standalone/io/file_system_exists_test.dart |
| @@ -0,0 +1,116 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import "dart:io"; |
| + |
| +void testFileExists() { |
| + var tmp = new Directory("").createTempSync(); |
| + var path = "${tmp.path}${Platform.pathSeparator}"; |
| + |
| + var file = new File("${path}myFile"); |
| + file.createSync(); |
| + |
| + Expect.isTrue(new File(file.path).existsSync()); |
| + Expect.isFalse(new Directory(file.path).existsSync()); |
| + Expect.isFalse(new Link(file.path).existsSync()); |
| + |
| + file.deleteSync(); |
| + Expect.isFalse(file.existsSync()); |
| + |
| + tmp.deleteSync(); |
| +} |
| + |
| +void testDirectoryExists() { |
| + var tmp = new Directory("").createTempSync(); |
| + var path = "${tmp.path}${Platform.pathSeparator}"; |
| + |
| + var dir = new Directory("${path}myDirectory"); |
| + dir.createSync(); |
| + |
| + Expect.isFalse(new File(dir.path).existsSync()); |
| + Expect.isTrue(new Directory(dir.path).existsSync()); |
| + Expect.isFalse(new Link(dir.path).existsSync()); |
| + |
| + dir.deleteSync(); |
| + Expect.isFalse(dir.existsSync()); |
| + |
| + tmp.deleteSync(); |
| +} |
| + |
| +void testFileLinkExists() { |
| + var tmp = new Directory("").createTempSync(); |
| + var path = "${tmp.path}${Platform.pathSeparator}"; |
| + |
| + var file = new File("${path}myFile"); |
| + file.createSync(); |
| + |
| + var link = new Link("${path}myLink"); |
| + link.createSync(file.path); |
| + |
| + Expect.isTrue(new File(link.path).existsSync()); |
| + Expect.isFalse(new Directory(link.path).existsSync()); |
| + Expect.isTrue(new Link(link.path).existsSync()); |
| + |
| + 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.
|
| + Expect.isFalse(link.existsSync()); |
| + |
| + file.deleteSync(); |
| + Expect.isFalse(file.existsSync()); |
| + |
| + tmp.deleteSync(); |
| +} |
| + |
| +void testDirectoryLinkExists() { |
| + var tmp = new Directory("").createTempSync(); |
| + var path = "${tmp.path}${Platform.pathSeparator}"; |
| + |
| + var directory = new Directory("${path}myDirectory"); |
| + directory.createSync(); |
| + |
| + var link = new Link("${path}myLink"); |
| + link.createSync(directory.path); |
| + |
| + Expect.isFalse(new File(link.path).existsSync()); |
| + Expect.isTrue(new Directory(link.path).existsSync()); |
| + Expect.isTrue(new Link(link.path).existsSync()); |
| + |
| + link.deleteSync(); |
|
Søren Gjesse
2013/04/05 12:52:50
Ditto.
Anders Johnsen
2013/04/08 06:50:49
Same.
|
| + Expect.isFalse(link.existsSync()); |
| + |
| + directory.deleteSync(); |
| + Expect.isFalse(directory.existsSync()); |
| + |
| + tmp.deleteSync(); |
| +} |
| + |
| +void testBrokenLinkExists() { |
| + var tmp = new Directory("").createTempSync(); |
| + var path = "${tmp.path}${Platform.pathSeparator}"; |
| + |
| + var directory = new Directory("${path}myDirectory"); |
| + directory.createSync(); |
| + |
| + var link = new Link("${path}myLink"); |
| + link.createSync(directory.path); |
| + directory.deleteSync(); |
| + |
| + Expect.isFalse(new File(link.path).existsSync()); |
| + Expect.isFalse(new Directory(link.path).existsSync()); |
| + Expect.isTrue(new Link(link.path).existsSync()); |
| + |
| + link.deleteSync(); |
| + Expect.isFalse(link.existsSync()); |
| + |
| + tmp.deleteSync(); |
| +} |
| + |
| +void main() { |
| + testFileExists(); |
| + testDirectoryExists(); |
| + // Not available on Windows. |
| + // testFileLinkExists(); |
| + testDirectoryLinkExists(); |
| + testBrokenLinkExists(); |
| +} |
| + |