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

Unified Diff: tests/standalone/src/FileTest.dart

Issue 9427014: Disallow opening of directories as files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
« no previous file with comments | « runtime/bin/file.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/FileTest.dart
diff --git a/tests/standalone/src/FileTest.dart b/tests/standalone/src/FileTest.dart
index 5b172bb088e4ab0486d23dbaeb186e37c88ff67d..b740ca3dd5d9ac06a16ab985aaa47e1805e87354 100644
--- a/tests/standalone/src/FileTest.dart
+++ b/tests/standalone/src/FileTest.dart
@@ -735,6 +735,22 @@ class FileTest {
f.exists();
}
+ static void testOpenDirectoryAsFile() {
+ var f = new File('.');
+ f.open();
+ f.openHandler = (r) => Expect.fail('Directory opened as file');
+ }
+
+ static void testOpenDirectoryAsFileSync() {
+ var f = new File('.');
+ try {
+ f.openSync();
+ Expect.fail("Expected exception opening directory as file");
+ } catch (var e) {
+ Expect.isTrue(e is FileIOException);
+ }
+ }
+
// Test that opens the same file for writing then for appending to test
// that the file is not truncated when opened for appending.
static void testAppend() {
@@ -809,6 +825,8 @@ class FileTest {
testPosition();
testPositionSync();
testMixedSyncAndAsync();
+ testOpenDirectoryAsFile();
+ testOpenDirectoryAsFileSync();
createTempDirectory(() {
testReadWrite();
« no previous file with comments | « runtime/bin/file.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698