| 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 // Dart test program for testing file I/O. | 5 // Dart test program for testing file I/O. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 port.toSendPort().send(1); | 1063 port.toSendPort().send(1); |
| 1064 }); | 1064 }); |
| 1065 }); | 1065 }); |
| 1066 }); | 1066 }); |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 static void testLastModified() { | 1069 static void testLastModified() { |
| 1070 var port = new ReceivePort(); | 1070 var port = new ReceivePort(); |
| 1071 new File(new Options().executable).lastModified().then((modified) { | 1071 new File(new Options().executable).lastModified().then((modified) { |
| 1072 Expect.isTrue(modified is DateTime); | 1072 Expect.isTrue(modified is DateTime); |
| 1073 Expect.isTrue(modified < new DateTime.now()); | 1073 Expect.isTrue(modified.isBefore(new DateTime.now())); |
| 1074 port.close(); | 1074 port.close(); |
| 1075 }); | 1075 }); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 static void testLastModifiedSync() { | 1078 static void testLastModifiedSync() { |
| 1079 var modified = new File(new Options().executable).lastModifiedSync(); | 1079 var modified = new File(new Options().executable).lastModifiedSync(); |
| 1080 Expect.isTrue(modified is DateTime); | 1080 Expect.isTrue(modified is DateTime); |
| 1081 Expect.isTrue(modified < new DateTime.now()); | 1081 Expect.isTrue(modified.isBefore(new DateTime.now())); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 // Test that opens the same file for writing then for appending to test | 1084 // Test that opens the same file for writing then for appending to test |
| 1085 // that the file is not truncated when opened for appending. | 1085 // that the file is not truncated when opened for appending. |
| 1086 static void testAppend() { | 1086 static void testAppend() { |
| 1087 var file = new File('${tempDirectory.path}/out_append'); | 1087 var file = new File('${tempDirectory.path}/out_append'); |
| 1088 file.open(mode: FileMode.WRITE).then((openedFile) { | 1088 file.open(mode: FileMode.WRITE).then((openedFile) { |
| 1089 openedFile.writeString("asdf").then((ignore) { | 1089 openedFile.writeString("asdf").then((ignore) { |
| 1090 openedFile.close().then((ignore) { | 1090 openedFile.close().then((ignore) { |
| 1091 file.open(mode: FileMode.APPEND).then((openedFile) { | 1091 file.open(mode: FileMode.APPEND).then((openedFile) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 testDirectorySync(); | 1237 testDirectorySync(); |
| 1238 testWriteStringUtf8(); | 1238 testWriteStringUtf8(); |
| 1239 testWriteStringUtf8Sync(); | 1239 testWriteStringUtf8Sync(); |
| 1240 }); | 1240 }); |
| 1241 } | 1241 } |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 main() { | 1244 main() { |
| 1245 FileTest.testMain(); | 1245 FileTest.testMain(); |
| 1246 } | 1246 } |
| OLD | NEW |