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