| 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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 521 } |
| 522 | 522 |
| 523 // Test for file write of different types of lists. | 523 // Test for file write of different types of lists. |
| 524 static void testWriteVariousLists() { | 524 static void testWriteVariousLists() { |
| 525 asyncTestStarted(); | 525 asyncTestStarted(); |
| 526 final String fileName = "${tempDirectory.path}/testWriteVariousLists"; | 526 final String fileName = "${tempDirectory.path}/testWriteVariousLists"; |
| 527 final File file = new File(fileName); | 527 final File file = new File(fileName); |
| 528 file.create().then((ignore) { | 528 file.create().then((ignore) { |
| 529 file.open(mode: WRITE).then((RandomAccessFile openedFile) { | 529 file.open(mode: WRITE).then((RandomAccessFile openedFile) { |
| 530 // Write bytes from 0 to 7. | 530 // Write bytes from 0 to 7. |
| 531 openedFile.writeFrom([0], 0, 1); | 531 openedFile.writeFromSync([0], 0, 1); |
| 532 openedFile.writeFrom(const [1], 0, 1); | 532 openedFile.writeFromSync(const [1], 0, 1); |
| 533 openedFile.writeFrom(new MyListOfOneElement(2), 0, 1); | 533 openedFile.writeFromSync(new MyListOfOneElement(2), 0, 1); |
| 534 var x = 12345678901234567890123456789012345678901234567890; | 534 var x = 12345678901234567890123456789012345678901234567890; |
| 535 var y = 12345678901234567890123456789012345678901234567893; | 535 var y = 12345678901234567890123456789012345678901234567893; |
| 536 openedFile.writeFrom([y - x], 0, 1); | 536 openedFile.writeFromSync([y - x], 0, 1); |
| 537 openedFile.writeFrom([260], 0, 1); // 260 = 256 + 4 = 0x104. | 537 openedFile.writeFromSync([260], 0, 1); // 260 = 256 + 4 = 0x104. |
| 538 openedFile.writeFrom(const [261], 0, 1); | 538 openedFile.writeFromSync(const [261], 0, 1); |
| 539 openedFile.writeFrom(new MyListOfOneElement(262), 0, 1); | 539 openedFile.writeFromSync(new MyListOfOneElement(262), 0, 1); |
| 540 x = 12345678901234567890123456789012345678901234567890; | 540 x = 12345678901234567890123456789012345678901234567890; |
| 541 y = 12345678901234567890123456789012345678901234568153; | 541 y = 12345678901234567890123456789012345678901234568153; |
| 542 openedFile.writeFrom([y - x], 0, 1).then((ignore) { | 542 openedFile.writeFrom([y - x], 0, 1).then((ignore) { |
| 543 openedFile.close().then((ignore) { | 543 openedFile.close().then((ignore) { |
| 544 // Check the written bytes. | 544 // Check the written bytes. |
| 545 final File file2 = new File(fileName); | 545 final File file2 = new File(fileName); |
| 546 var openedFile2 = file2.openSync(); | 546 var openedFile2 = file2.openSync(); |
| 547 var length = openedFile2.lengthSync(); | 547 var length = openedFile2.lengthSync(); |
| 548 Expect.equals(8, length); | 548 Expect.equals(8, length); |
| 549 List data = new List(length); | 549 List data = new List(length); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 testRenameSync(); | 1301 testRenameSync(); |
| 1302 testLastModified(); | 1302 testLastModified(); |
| 1303 asyncEnd(); | 1303 asyncEnd(); |
| 1304 }); | 1304 }); |
| 1305 } | 1305 } |
| 1306 } | 1306 } |
| 1307 | 1307 |
| 1308 main() { | 1308 main() { |
| 1309 FileTest.testMain(); | 1309 FileTest.testMain(); |
| 1310 } | 1310 } |
| OLD | NEW |