Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: tests/standalone/io/file_test.dart

Issue 17033003: dart:io | Add File.rename (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added comments 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 side-by-side diff with in-line comments
Download patch
« runtime/bin/file_android.cc ('K') | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_test.dart
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index b931475e23f23edeb843b3adc3d501f502a7526c..cdde84fa319b717871cb4f81388bd5576a0cb564 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -1218,6 +1218,39 @@ class FileTest {
Expect.isFalse(file.existsSync());
}
+ // Test that opens the same file for writing then for appending to test
Anders Johnsen 2013/06/14 07:54:35 Add test for rename of broken link. (Should fail,
Søren Gjesse 2013/06/14 11:00:10 Done.
+ // that the file is not truncated when opened for appending.
+ static void testRename() {
+ var file = new File('${tempDirectory.path}/rename_name');
+ file.create().then((file) {
+ file.rename("${tempDirectory.path}/rename_newname").then((newfile) {
+ file.exists().then((e) {
+ Expect.isFalse(e);
+ newfile.exists().then((e) {
+ Expect.isTrue(e);
+ newfile.delete().then((_) {
+ file.exists().then((e) {
+ Expect.isFalse(e);
+ asyncTestDone("testRename");
+ });
+ });
+ });
+ });
+ });
+ });
+ asyncTestStarted();
+ }
+
+ static void testRenameSync() {
+ var file = new File('${tempDirectory.path}/rename_name_sync');
+ file.createSync();
+ var newfile = file.renameSync('${tempDirectory.path}/rename_newname_sync');
+ Expect.isFalse(file.existsSync());
+ Expect.isTrue(newfile.existsSync());
+ newfile.deleteSync();
+ Expect.isFalse(newfile.existsSync());
+ }
+
// Helper method to be able to run the test from the runtime
// directory, or the top directory.
static String getFilename(String path) =>
@@ -1276,6 +1309,8 @@ class FileTest {
testDirectorySync();
testWriteStringUtf8();
testWriteStringUtf8Sync();
+ testRename();
+ testRenameSync();
});
}
}
« runtime/bin/file_android.cc ('K') | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698