OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 .catchError((e) { | 1146 .catchError((e) { |
1147 port.toSendPort().send(1); | 1147 port.toSendPort().send(1); |
1148 }); | 1148 }); |
1149 }); | 1149 }); |
1150 }); | 1150 }); |
1151 } | 1151 } |
1152 | 1152 |
1153 static void testLastModified() { | 1153 static void testLastModified() { |
1154 var port = new ReceivePort(); | 1154 var port = new ReceivePort(); |
1155 new File(new Options().executable).lastModified().then((modified) { | 1155 new File(new Options().executable).lastModified().then((modified) { |
1156 Expect.isTrue(modified is Date); | 1156 Expect.isTrue(modified is DateTime); |
1157 Expect.isTrue(modified < new Date.now()); | 1157 Expect.isTrue(modified < new DateTime.now()); |
1158 port.close(); | 1158 port.close(); |
1159 }); | 1159 }); |
1160 } | 1160 } |
1161 | 1161 |
1162 static void testLastModifiedSync() { | 1162 static void testLastModifiedSync() { |
1163 var modified = new File(new Options().executable).lastModifiedSync(); | 1163 var modified = new File(new Options().executable).lastModifiedSync(); |
1164 Expect.isTrue(modified is Date); | 1164 Expect.isTrue(modified is DateTime); |
1165 Expect.isTrue(modified < new Date.now()); | 1165 Expect.isTrue(modified < new DateTime.now()); |
1166 } | 1166 } |
1167 | 1167 |
1168 // Test that opens the same file for writing then for appending to test | 1168 // Test that opens the same file for writing then for appending to test |
1169 // that the file is not truncated when opened for appending. | 1169 // that the file is not truncated when opened for appending. |
1170 static void testAppend() { | 1170 static void testAppend() { |
1171 var file = new File('${tempDirectory.path}/out_append'); | 1171 var file = new File('${tempDirectory.path}/out_append'); |
1172 file.open(FileMode.WRITE).then((openedFile) { | 1172 file.open(FileMode.WRITE).then((openedFile) { |
1173 openedFile.writeString("asdf").then((ignore) { | 1173 openedFile.writeString("asdf").then((ignore) { |
1174 openedFile.close().then((ignore) { | 1174 openedFile.close().then((ignore) { |
1175 file.open(FileMode.APPEND).then((openedFile) { | 1175 file.open(FileMode.APPEND).then((openedFile) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 testDirectorySync(); | 1321 testDirectorySync(); |
1322 testWriteStringUtf8(); | 1322 testWriteStringUtf8(); |
1323 testWriteStringUtf8Sync(); | 1323 testWriteStringUtf8Sync(); |
1324 }); | 1324 }); |
1325 } | 1325 } |
1326 } | 1326 } |
1327 | 1327 |
1328 main() { | 1328 main() { |
1329 FileTest.testMain(); | 1329 FileTest.testMain(); |
1330 } | 1330 } |
OLD | NEW |