| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 Expect.equals(false, writeDone); | 122 Expect.equals(false, writeDone); |
| 123 output.noPendingWriteHandler = () { | 123 output.noPendingWriteHandler = () { |
| 124 output.close(); | 124 output.close(); |
| 125 | 125 |
| 126 // Now read the contents of the file just written. | 126 // Now read the contents of the file just written. |
| 127 List<int> buffer2 = new List<int>(42); | 127 List<int> buffer2 = new List<int>(42); |
| 128 file = new File(outFilename); | 128 file = new File(outFilename); |
| 129 input = file.openInputStream(); | 129 input = file.openInputStream(); |
| 130 input.dataHandler = () { | 130 input.dataHandler = () { |
| 131 bytesRead = input.readInto(buffer2, 0, 42); | 131 bytesRead = input.readInto(buffer2, 0, 42); |
| 132 Expect.isTrue(input.closed); | |
| 133 Expect.equals(42, bytesRead); | 132 Expect.equals(42, bytesRead); |
| 134 // Now compare the two buffers to check if they are identical. | 133 // Now compare the two buffers to check if they are identical. |
| 135 for (int i = 0; i < buffer1.length; i++) { | 134 for (int i = 0; i < buffer1.length; i++) { |
| 136 Expect.equals(buffer1[i], buffer2[i]); | 135 Expect.equals(buffer1[i], buffer2[i]); |
| 137 } | 136 } |
| 138 // Delete the output file. | 137 input.closeHandler = () { |
| 139 file.deleteSync(); | 138 // Delete the output file. |
| 140 Expect.isFalse(file.existsSync()); | 139 file.deleteSync(); |
| 141 asyncTestDone("testReadWriteStream"); | 140 Expect.isFalse(file.existsSync()); |
| 141 asyncTestDone("testReadWriteStream"); |
| 142 }; |
| 142 }; | 143 }; |
| 143 }; | 144 }; |
| 144 }; | 145 }; |
| 145 }; | 146 }; |
| 146 }; | 147 }; |
| 147 }; | 148 }; |
| 148 } | 149 } |
| 149 | 150 |
| 150 static void testRead() { | 151 static void testRead() { |
| 151 // Read a file and check part of it's contents. | 152 // Read a file and check part of it's contents. |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 testWriteVariousLists(); | 1147 testWriteVariousLists(); |
| 1147 testDirectory(); | 1148 testDirectory(); |
| 1148 testDirectorySync(); | 1149 testDirectorySync(); |
| 1149 }); | 1150 }); |
| 1150 } | 1151 } |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 main() { | 1154 main() { |
| 1154 FileTest.testMain(); | 1155 FileTest.testMain(); |
| 1155 } | 1156 } |
| OLD | NEW |