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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 Expect.equals(0, bytesRead); | 209 Expect.equals(0, bytesRead); |
210 Expect.equals(0, input.available()); | 210 Expect.equals(0, input.available()); |
211 Expect.isFalse(input.closed); | 211 Expect.isFalse(input.closed); |
212 input.onError = (e) { | 212 input.onError = (e) { |
213 print('Error handler called on input in testReadWriteStreamLargeFile'); | 213 print('Error handler called on input in testReadWriteStreamLargeFile'); |
214 print('with error $e'); | 214 print('with error $e'); |
215 throw e; | 215 throw e; |
216 }; | 216 }; |
217 input.onData = () { | 217 input.onData = () { |
218 Expect.isFalse(input.closed); | 218 Expect.isFalse(input.closed); |
219 bytesRead = input.readInto(inputBuffer, offset: position, | 219 bytesRead = input.readInto(inputBuffer, position, |
220 len: inputBuffer.length - position); | 220 inputBuffer.length - position); |
221 position += bytesRead; | 221 position += bytesRead; |
222 // The buffer is large enough to hold all available data. | 222 // The buffer is large enough to hold all available data. |
223 // So there should be no data left to read. | 223 // So there should be no data left to read. |
224 Expect.equals(0, input.available()); | 224 Expect.equals(0, input.available()); |
225 bytesRead = input.readInto(inputBuffer, offset: position, | 225 bytesRead = input.readInto(inputBuffer, position, |
226 len: expectedLength - position); | 226 expectedLength - position); |
227 Expect.equals(0, bytesRead); | 227 Expect.equals(0, bytesRead); |
228 Expect.equals(0, input.available()); | 228 Expect.equals(0, input.available()); |
229 Expect.isFalse(input.closed); | 229 Expect.isFalse(input.closed); |
230 }; | 230 }; |
231 input.onClosed = () { | 231 input.onClosed = () { |
232 Expect.equals(0, input.available()); | 232 Expect.equals(0, input.available()); |
233 Expect.isTrue(input.closed); | 233 Expect.isTrue(input.closed); |
234 input.close(); // This should be safe to call. | 234 input.close(); // This should be safe to call. |
235 | 235 |
236 Expect.equals(expectedLength, position); | 236 Expect.equals(expectedLength, position); |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 testWriteVariousLists(); | 1273 testWriteVariousLists(); |
1274 testDirectory(); | 1274 testDirectory(); |
1275 testDirectorySync(); | 1275 testDirectorySync(); |
1276 }); | 1276 }); |
1277 } | 1277 } |
1278 } | 1278 } |
1279 | 1279 |
1280 main() { | 1280 main() { |
1281 FileTest.testMain(); | 1281 FileTest.testMain(); |
1282 } | 1282 } |
OLD | NEW |