Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: tests/standalone/io/file_test.dart

Issue 233053004: Fix File:copy FD leak, and add file-closes to some tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 Expect.equals(32, buffer[2]); // represents ' ' in the file. 255 Expect.equals(32, buffer[2]); // represents ' ' in the file.
256 Expect.equals(67, buffer[3]); // represents 'C' in the file. 256 Expect.equals(67, buffer[3]); // represents 'C' in the file.
257 Expect.equals(111, buffer[4]); // represents 'o' in the file. 257 Expect.equals(111, buffer[4]); // represents 'o' in the file.
258 Expect.equals(112, buffer[5]); // represents 'p' in the file. 258 Expect.equals(112, buffer[5]); // represents 'p' in the file.
259 Expect.equals(121, buffer[6]); // represents 'y' in the file. 259 Expect.equals(121, buffer[6]); // represents 'y' in the file.
260 Expect.equals(114, buffer[7]); // represents 'r' in the file. 260 Expect.equals(114, buffer[7]); // represents 'r' in the file.
261 Expect.equals(105, buffer[8]); // represents 'i' in the file. 261 Expect.equals(105, buffer[8]); // represents 'i' in the file.
262 Expect.equals(103, buffer[9]); // represents 'g' in the file. 262 Expect.equals(103, buffer[9]); // represents 'g' in the file.
263 Expect.equals(104, buffer[10]); // represents 'h' in the file. 263 Expect.equals(104, buffer[10]); // represents 'h' in the file.
264 Expect.equals(116, buffer[11]); // represents 't' in the file. 264 Expect.equals(116, buffer[11]); // represents 't' in the file.
265 raf.closeSync();
265 266
266 filename = getFilename("tests/vm/data/fixed_length_file"); 267 filename = getFilename("tests/vm/data/fixed_length_file");
267 File file = new File(filename); 268 File file = new File(filename);
268 int len = file.lengthSync(); 269 int len = file.lengthSync();
269 Expect.equals(0, file.openSync().readSync(0).length); 270 int read(int length) {
270 Expect.equals(1, file.openSync().readSync(1).length); 271 var f = file.openSync();
271 Expect.equals(len - 1, file.openSync().readSync(len - 1).length); 272 int res = f.readSync(length).length;
272 Expect.equals(len, file.openSync().readSync(len).length); 273 f.closeSync();
273 Expect.equals(len, file.openSync().readSync(len + 1).length); 274 return res;
274 Expect.equals(len, file.openSync().readSync(len * 2).length); 275 }
275 Expect.equals(len, file.openSync().readSync(len * 10).length); 276 Expect.equals(0, read(0));
277 Expect.equals(1, read(1));
278 Expect.equals(len - 1, read(len - 1));
279 Expect.equals(len, read(len));
280 Expect.equals(len, read(len + 1));
281 Expect.equals(len, read(len * 2));
282 Expect.equals(len, read(len * 10));
276 } 283 }
277 284
278 // Test for file read and write functionality. 285 // Test for file read and write functionality.
279 static void testReadWrite() { 286 static void testReadWrite() {
280 asyncTestStarted(); 287 asyncTestStarted();
281 // Read a file. 288 // Read a file.
282 String inFilename = getFilename("tests/vm/data/fixed_length_file"); 289 String inFilename = getFilename("tests/vm/data/fixed_length_file");
283 final File file = new File(inFilename); 290 final File file = new File(inFilename);
284 file.open(mode: READ).then((openedFile) { 291 file.open(mode: READ).then((openedFile) {
285 List<int> buffer1 = new List<int>(42); 292 List<int> buffer1 = new List<int>(42);
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 testLastModified(); 1336 testLastModified();
1330 testDoubleAsyncOperation(); 1337 testDoubleAsyncOperation();
1331 asyncEnd(); 1338 asyncEnd();
1332 }); 1339 });
1333 } 1340 }
1334 } 1341 }
1335 1342
1336 main() { 1343 main() {
1337 FileTest.testMain(); 1344 FileTest.testMain();
1338 } 1345 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_invalid_arguments_test.dart ('k') | tests/standalone/io/read_into_const_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698