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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/file_test.dart
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index f8e93c92b0cb763e0fcadc2a02d16ec5f65922af..0ce18aeabb4b0e494bfed255c8f316741442f8ab 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -262,17 +262,24 @@ class FileTest {
Expect.equals(103, buffer[9]); // represents 'g' in the file.
Expect.equals(104, buffer[10]); // represents 'h' in the file.
Expect.equals(116, buffer[11]); // represents 't' in the file.
+ raf.closeSync();
filename = getFilename("tests/vm/data/fixed_length_file");
File file = new File(filename);
int len = file.lengthSync();
- Expect.equals(0, file.openSync().readSync(0).length);
- Expect.equals(1, file.openSync().readSync(1).length);
- Expect.equals(len - 1, file.openSync().readSync(len - 1).length);
- Expect.equals(len, file.openSync().readSync(len).length);
- Expect.equals(len, file.openSync().readSync(len + 1).length);
- Expect.equals(len, file.openSync().readSync(len * 2).length);
- Expect.equals(len, file.openSync().readSync(len * 10).length);
+ int read(int length) {
+ var f = file.openSync();
+ int res = f.readSync(length).length;
+ f.closeSync();
+ return res;
+ }
+ Expect.equals(0, read(0));
+ Expect.equals(1, read(1));
+ Expect.equals(len - 1, read(len - 1));
+ Expect.equals(len, read(len));
+ Expect.equals(len, read(len + 1));
+ Expect.equals(len, read(len * 2));
+ Expect.equals(len, read(len * 10));
}
// Test for file read and write functionality.
« 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