Index: tests/standalone/io/file_system_delete_test.dart |
diff --git a/tests/standalone/io/file_system_delete_test.dart b/tests/standalone/io/file_system_delete_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dc2864d0b1421ce65bbda9b4072f3046652b0ce0 |
--- /dev/null |
+++ b/tests/standalone/io/file_system_delete_test.dart |
@@ -0,0 +1,197 @@ |
+// 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 testDeleteFile() { |
+ var tmp = new Directory("").createTempSync(); |
+ var path = "${tmp.path}${Platform.pathSeparator}"; |
+ |
+ var file = new File("${path}myFile"); |
+ |
+ file.createSync(); |
+ |
+ Expect.isTrue(file.existsSync()); |
+ new File(file.path).deleteSync(); |
+ Expect.isFalse(file.existsSync()); |
+ |
+ file.createSync(); |
+ |
+ Expect.isTrue(file.existsSync()); |
+ Expect.throws(() => new Directory(file.path).deleteSync()); |
+ Expect.isTrue(file.existsSync()); |
+ |
+ Expect.isTrue(file.existsSync()); |
+ Expect.throws(() => new Directory(file.path).deleteSync(recursive: true)); |
+ Expect.isTrue(file.existsSync()); |
+ |
+ Expect.isTrue(file.existsSync()); |
+ Expect.throws(() => new Link(file.path).deleteSync()); |
+ Expect.isTrue(file.existsSync()); |
+ |
+ file.deleteSync(); |
+ Expect.isFalse(file.existsSync()); |
+ |
+ tmp.deleteSync(); |
+} |
+ |
+void testDeleteDirectory() { |
+ var dir = new Directory("myDirectory"); |
+ |
+ dir.createSync(); |
+ |
+ Expect.isTrue(dir.existsSync()); |
+ new Directory(dir.path).deleteSync(); |
+ Expect.isFalse(dir.existsSync()); |
+ |
+ dir.createSync(); |
+ |
+ Expect.isTrue(dir.existsSync()); |
+ new Directory(dir.path).deleteSync(recursive: true); |
+ Expect.isFalse(dir.existsSync()); |
+ |
+ dir.createSync(); |
+ |
+ Expect.isTrue(dir.existsSync()); |
+ Expect.throws(() => new File(dir.path).deleteSync()); |
+ Expect.isTrue(dir.existsSync()); |
+ |
+ Expect.isTrue(dir.existsSync()); |
+ Expect.throws(() => new Link(dir.path).deleteSync()); |
+ Expect.isTrue(dir.existsSync()); |
+ |
+ dir.deleteSync(); |
+ Expect.isFalse(dir.existsSync()); |
+} |
+ |
+void testDeleteFileLink() { |
+ 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(link.existsSync()); |
+ new File(link.path).deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ link.createSync(file.path); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ new Link(link.path).deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
Søren Gjesse
2013/04/05 12:52:50
Add
Expect.isFalse(new File(link.path).existsSync
Anders Johnsen
2013/04/08 06:50:49
These kinds of 'exists' tests are tested in the fi
|
+ |
+ link.createSync(file.path); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ Expect.throws(() => new Directory(link.path).deleteSync()); |
+ Expect.isTrue(link.existsSync()); |
Søren Gjesse
2013/04/05 12:52:50
Add
Expect.isTrue(new File(link.path).existsSync(
Anders Johnsen
2013/04/08 06:50:49
Ditto
|
+ |
+ Expect.isTrue(link.existsSync()); |
+ Expect.throws(() => new Directory(link.path).deleteSync(recursive: true)); |
+ Expect.isTrue(link.existsSync()); |
+ |
+ link.deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ Expect.isTrue(file.existsSync()); |
+ file.deleteSync(); |
+ Expect.isFalse(file.existsSync()); |
+ |
+ tmp.deleteSync(); |
+} |
+ |
+void testDeleteDirectoryLink() { |
+ 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.isTrue(link.existsSync()); |
+ new Link(link.path).deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ link.createSync(directory.path); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ new Directory(link.path).deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ link.createSync(directory.path); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ new Directory(link.path).deleteSync(recursive: true); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ link.createSync(directory.path); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ Expect.throws(() => new File(link.path).deleteSync()); |
+ Expect.isTrue(link.existsSync()); |
+ |
+ link.deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ Expect.isTrue(directory.existsSync()); |
+ directory.deleteSync(); |
+ Expect.isFalse(directory.existsSync()); |
+ |
+ tmp.deleteSync(); |
+} |
+ |
+void testDeleteBrokenLink() { |
+ 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.isTrue(link.existsSync()); |
+ new Link(link.path).deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ directory.createSync(); |
+ link.createSync(directory.path); |
+ directory.deleteSync(); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ Expect.throws(() => new Directory(link.path).deleteSync()); |
+ Expect.isTrue(link.existsSync()); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ Expect.throws(() => new Directory(link.path).deleteSync(recursive: true)); |
+ Expect.isTrue(link.existsSync()); |
+ |
+ Expect.isTrue(link.existsSync()); |
+ Expect.throws(() => new File(link.path).deleteSync()); |
+ Expect.isTrue(link.existsSync()); |
+ |
+ link.deleteSync(); |
+ Expect.isFalse(link.existsSync()); |
+ |
+ tmp.deleteSync(); |
+} |
+ |
+void main() { |
+ testDeleteFile(); |
+ testDeleteDirectory(); |
+ // Not available on Windows. |
Søren Gjesse
2013/04/05 12:52:50
Just use
if (Platform.operatingSystem != 'wind
Anders Johnsen
2013/04/08 06:50:49
Done.
|
+ //testDeleteFileLink(); |
+ testDeleteDirectoryLink(); |
+ testDeleteBrokenLink(); |
+} |