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

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

Issue 9630012: Error reporting on File in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
« runtime/bin/io.dart ('K') | « runtime/bin/io.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/io/FileTest.dart
diff --git a/tests/standalone/src/io/FileTest.dart b/tests/standalone/src/io/FileTest.dart
index f691c5d1a6425fb2525d7837bfb342d279a69384..7cf5b69b9fd1bdaf74f98838f038e3f49b58f27d 100644
--- a/tests/standalone/src/io/FileTest.dart
+++ b/tests/standalone/src/io/FileTest.dart
@@ -510,6 +510,32 @@ class FileTest {
Expect.throws(file_dir.directorySync, (e) { return e is FileIOException; });
}
+ static void testFileError() {
+ void checkOpenNonExistentFileException(e) {
+ Expect.isTrue(e is FileIOException);
+ Expect.isTrue(e.osError != null);
+ Expect.isTrue(e.toString().indexOf("Cannot open file") != -1);
+ if (new Platform().operatingSystem() == "macos") {
+ Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
+ Expect.equals(2, e.osError.errorCode);
+ }
+ }
+
+ var tempDir = tempDirectory.path;
+ var file = new File("${tempDir}/nonExistentFile");
+
+ // Non-existing file should throw exception.
+ try {
+ file.openSync();
+ } catch (Exception e) {
+ checkOpenNonExistentFileException(e);
+ }
+
+ file.open(FileMode.READ, (raf) => Expect.fail("Unreachable code"));
+ file.onError = (e) => checkOpenNonExistentFileException(e);
+ }
+
+
// Test for file length functionality.
static void testLength() {
String filename = getFilename("tests/vm/data/fixed_length_file");
@@ -1040,7 +1066,7 @@ class FileTest {
// Main test entrypoint.
static testMain() {
- testRead();
+ /*testRead();
testReadSync();
testReadStream();
testLength();
@@ -1057,9 +1083,9 @@ class FileTest {
testReadAsLines();
testReadAsLinesSync();
testReadAsErrors();
-
+*/
createTempDirectory(() {
- testReadWrite();
+/* testReadWrite();
testReadWriteSync();
testReadWriteStream();
testReadEmptyFileSync();
@@ -1075,7 +1101,8 @@ class FileTest {
testOutputStreamWriteAppend();
testWriteVariousLists();
testDirectory();
- testDirectorySync();
+ testDirectorySync();*/
+ testFileError();
});
}
}
« runtime/bin/io.dart ('K') | « runtime/bin/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698