| 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:io"); | 7 #import("dart:io"); |
| 8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 9 | 9 |
| 10 class MyListOfOneElement implements List { | 10 class MyListOfOneElement implements List { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // Directories should throw exception. | 524 // Directories should throw exception. |
| 525 var file_dir = new File("."); | 525 var file_dir = new File("."); |
| 526 Expect.throws(file_dir.directorySync, (e) { return e is FileIOException; }); | 526 Expect.throws(file_dir.directorySync, (e) { return e is FileIOException; }); |
| 527 file_dir = new File(tempDir); | 527 file_dir = new File(tempDir); |
| 528 Expect.throws(file_dir.directorySync, (e) { return e is FileIOException; }); | 528 Expect.throws(file_dir.directorySync, (e) { return e is FileIOException; }); |
| 529 } | 529 } |
| 530 | 530 |
| 531 // Test for file length functionality. | 531 // Test for file length functionality. |
| 532 static void testLength() { | 532 static void testLength() { |
| 533 String filename = getFilename("tests/vm/data/fixed_length_file"); | 533 String filename = getFilename("tests/vm/data/fixed_length_file"); |
| 534 RandomAccessFile input = (new File(filename)).openSync(); | 534 File file = new File(filename); |
| 535 input.onError = (e) => Expect.fail("No errors expected"); | 535 RandomAccessFile openedFile = file.openSync(); |
| 536 input.length((length) { | 536 openedFile.onError = (e) => Expect.fail("No errors expected"); |
| 537 file.onError = (e) => Expect.fail("No errors expected"); |
| 538 openedFile.length((length) { |
| 537 Expect.equals(42, length); | 539 Expect.equals(42, length); |
| 538 input.close(() => null); | 540 openedFile.close(() => null); |
| 541 }); |
| 542 file.length((length) { |
| 543 Expect.equals(42, length); |
| 539 }); | 544 }); |
| 540 } | 545 } |
| 541 | 546 |
| 542 static void testLengthSync() { | 547 static void testLengthSync() { |
| 543 String filename = getFilename("tests/vm/data/fixed_length_file"); | 548 String filename = getFilename("tests/vm/data/fixed_length_file"); |
| 544 RandomAccessFile input = (new File(filename)).openSync(); | 549 File file = new File(filename); |
| 545 Expect.equals(42, input.lengthSync()); | 550 RandomAccessFile openedFile = file.openSync(); |
| 546 input.closeSync(); | 551 Expect.equals(42, file.lengthSync()); |
| 552 Expect.equals(42, openedFile.lengthSync()); |
| 553 openedFile.closeSync(); |
| 547 } | 554 } |
| 548 | 555 |
| 549 // Test for file position functionality. | 556 // Test for file position functionality. |
| 550 static void testPosition() { | 557 static void testPosition() { |
| 551 String filename = getFilename("tests/vm/data/fixed_length_file"); | 558 String filename = getFilename("tests/vm/data/fixed_length_file"); |
| 552 RandomAccessFile input = (new File(filename)).openSync(); | 559 RandomAccessFile input = (new File(filename)).openSync(); |
| 553 input.onError = (e) => Expect.fail("No errors expected"); | 560 input.onError = (e) => Expect.fail("No errors expected"); |
| 554 input.position((position) { | 561 input.position((position) { |
| 555 Expect.equals(0, position); | 562 Expect.equals(0, position); |
| 556 List<int> buffer = new List<int>(100); | 563 List<int> buffer = new List<int>(100); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 testWriteVariousLists(); | 1078 testWriteVariousLists(); |
| 1072 testDirectory(); | 1079 testDirectory(); |
| 1073 testDirectorySync(); | 1080 testDirectorySync(); |
| 1074 }); | 1081 }); |
| 1075 } | 1082 } |
| 1076 } | 1083 } |
| 1077 | 1084 |
| 1078 main() { | 1085 main() { |
| 1079 FileTest.testMain(); | 1086 FileTest.testMain(); |
| 1080 } | 1087 } |
| OLD | NEW |