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

Side by Side Diff: tests/standalone/io/file_input_stream_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
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | tests/standalone/io/file_invalid_arguments_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Testing file input stream, VM-only, standalone test. 4 // Testing file input stream, VM-only, standalone test.
5 5
6 import "dart:convert"; 6 import "dart:convert";
7 import "dart:io"; 7 import "dart:io";
8 8
9 import "package:async_helper/async_helper.dart"; 9 import "package:async_helper/async_helper.dart";
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 test(-1, null); 226 test(-1, null);
227 test(100, 99); 227 test(100, 99);
228 test(null, -1); 228 test(null, -1);
229 } 229 }
230 230
231 231
232 void testStringLineSplitterEnding(String name, int length) { 232 void testStringLineSplitterEnding(String name, int length) {
233 String fileName = getFilename("tests/standalone/io/$name"); 233 String fileName = getFilename("tests/standalone/io/$name");
234 // File contains 10 lines. 234 // File contains 10 lines.
235 File file = new File(fileName); 235 File file = new File(fileName);
236 Expect.equals(length, file.openSync().lengthSync()); 236 Expect.equals(length, file.lengthSync());
237 var lineStream = file.openRead() 237 var lineStream = file.openRead()
238 .transform(UTF8.decoder) 238 .transform(UTF8.decoder)
239 .transform(new LineSplitter()); 239 .transform(new LineSplitter());
240 int lineCount = 0; 240 int lineCount = 0;
241 lineStream.listen( 241 lineStream.listen(
242 (line) { 242 (line) {
243 lineCount++; 243 lineCount++;
244 Expect.isTrue(lineCount <= 10); 244 Expect.isTrue(lineCount <= 10);
245 if (line[0] != "#") { 245 if (line[0] != "#") {
246 Expect.equals("Line $lineCount", line); 246 Expect.equals("Line $lineCount", line);
(...skipping 12 matching lines...) Expand all
259 testInputStreamDelete(); 259 testInputStreamDelete();
260 testInputStreamAppend(); 260 testInputStreamAppend();
261 testInputStreamOffset(); 261 testInputStreamOffset();
262 testInputStreamBadOffset(); 262 testInputStreamBadOffset();
263 // Check the length of these files as both are text files where one 263 // Check the length of these files as both are text files where one
264 // is without a terminating line separator which can easily be added 264 // is without a terminating line separator which can easily be added
265 // back if accidentally opened in a text editor. 265 // back if accidentally opened in a text editor.
266 testStringLineSplitterEnding("readline_test1.dat", 111); 266 testStringLineSplitterEnding("readline_test1.dat", 111);
267 testStringLineSplitterEnding("readline_test2.dat", 114); 267 testStringLineSplitterEnding("readline_test2.dat", 114);
268 } 268 }
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | tests/standalone/io/file_invalid_arguments_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698