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 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 static void testOpenDirectoryAsFileSync() { | 913 static void testOpenDirectoryAsFileSync() { |
914 var f = new File('.'); | 914 var f = new File('.'); |
915 try { | 915 try { |
916 f.openSync(); | 916 f.openSync(); |
917 Expect.fail("Expected exception opening directory as file"); | 917 Expect.fail("Expected exception opening directory as file"); |
918 } catch (e) { | 918 } catch (e) { |
919 Expect.isTrue(e is FileException); | 919 Expect.isTrue(e is FileException); |
920 } | 920 } |
921 } | 921 } |
922 | 922 |
923 static void testOpenFile() { | |
924 var name = getFilename("tests/vm/data/fixed_length_file"); | |
925 var f = new File(name); | |
926 Expect.isTrue(f.existsSync()); | |
927 name = f.fullPathSync(); | |
928 var g = new File(name); | |
929 Expect.isTrue(g.existsSync()); | |
930 Expect.equals(name, g.fullPathSync()); | |
931 } | |
932 | |
933 static void testReadAsBytes() { | 923 static void testReadAsBytes() { |
934 asyncTestStarted(); | 924 asyncTestStarted(); |
935 var name = getFilename("tests/vm/data/fixed_length_file"); | 925 var name = getFilename("tests/vm/data/fixed_length_file"); |
936 var f = new File(name); | 926 var f = new File(name); |
937 f.readAsBytes().then((bytes) { | 927 f.readAsBytes().then((bytes) { |
938 Expect.isTrue(new String.fromCharCodes(bytes).endsWith("42 bytes.")); | 928 Expect.isTrue(new String.fromCharCodes(bytes).endsWith("42 bytes.")); |
939 Expect.equals(42, bytes.length); | 929 Expect.equals(42, bytes.length); |
940 asyncTestDone("testReadAsBytes"); | 930 asyncTestDone("testReadAsBytes"); |
941 }); | 931 }); |
942 } | 932 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 static testMain() { | 1252 static testMain() { |
1263 asyncStart(); | 1253 asyncStart(); |
1264 | 1254 |
1265 testRead(); | 1255 testRead(); |
1266 testReadSync(); | 1256 testReadSync(); |
1267 testReadStream(); | 1257 testReadStream(); |
1268 testLengthSync(); | 1258 testLengthSync(); |
1269 testPositionSync(); | 1259 testPositionSync(); |
1270 testOpenDirectoryAsFile(); | 1260 testOpenDirectoryAsFile(); |
1271 testOpenDirectoryAsFileSync(); | 1261 testOpenDirectoryAsFileSync(); |
1272 testOpenFile(); | |
1273 testReadAsBytesSync(); | 1262 testReadAsBytesSync(); |
1274 testReadAsBytesSyncEmptyFile(); | 1263 testReadAsBytesSyncEmptyFile(); |
1275 testReadAsTextSync(); | 1264 testReadAsTextSync(); |
1276 testReadAsTextSyncEmptyFile(); | 1265 testReadAsTextSyncEmptyFile(); |
1277 testReadAsLinesSync(); | 1266 testReadAsLinesSync(); |
1278 testLastModifiedSync(); | 1267 testLastModifiedSync(); |
1279 | 1268 |
1280 createTempDirectory(() { | 1269 createTempDirectory(() { |
1281 testLength(); | 1270 testLength(); |
1282 testReadWrite(); | 1271 testReadWrite(); |
(...skipping 29 matching lines...) Expand all Loading... |
1312 testRenameSync(); | 1301 testRenameSync(); |
1313 testLastModified(); | 1302 testLastModified(); |
1314 asyncEnd(); | 1303 asyncEnd(); |
1315 }); | 1304 }); |
1316 } | 1305 } |
1317 } | 1306 } |
1318 | 1307 |
1319 main() { | 1308 main() { |
1320 FileTest.testMain(); | 1309 FileTest.testMain(); |
1321 } | 1310 } |
OLD | NEW |