Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 error handling in file I/O. | 5 // Dart test program for testing error handling in file I/O. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 import "dart:isolate"; | 9 import "dart:isolate"; |
| 10 | 10 |
| 11 Directory tempDir() { | 11 Directory tempDir() { |
| 12 return new Directory('').createTempSync(); | 12 return new Directory('').createTempSync(); |
| 13 } | 13 } |
| 14 | 14 |
| 15 | 15 |
| 16 bool checkNonExistentFileException(e, str) { | 16 bool checkNonExistentFileException(e, str) { |
| 17 Expect.isTrue(e is FileException); | 17 Expect.isTrue(e is FileException); |
| 18 Expect.isTrue(e.osError != null); | 18 Expect.isTrue(e.osError != null); |
| 19 Expect.isTrue(e.toString().indexOf(str) != -1); | 19 Expect.isTrue(e.toString().indexOf(str) != -1); |
| 20 // File not not found has error code 2 on all supported platforms. | 20 // File not not found has error code 2 on all supported platforms. |
| 21 Expect.equals(2, e.osError.errorCode); | 21 Expect.equals(2, e.osError.errorCode); |
| 22 return true; | 22 return true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 | 25 |
| 26 bool checkOpenNonExistentFileException(e) { | 26 bool checkOpenNonExistentFileException(e) { |
| 27 print(e); | |
|
Bill Hesse
2013/06/27 16:32:46
Stray print statement.
Anders Johnsen
2013/06/27 16:42:19
Done.
| |
| 27 return checkNonExistentFileException(e, "Cannot open file"); | 28 return checkNonExistentFileException(e, "Cannot open file"); |
| 28 } | 29 } |
| 29 | 30 |
| 30 | 31 |
| 31 bool checkDeleteNonExistentFileException(e) { | 32 bool checkDeleteNonExistentFileException(e) { |
| 32 return checkNonExistentFileException(e, "Cannot delete file"); | 33 return checkNonExistentFileException(e, "Cannot delete file"); |
| 33 } | 34 } |
| 34 | 35 |
| 35 | 36 |
| 36 bool checkLengthNonExistentFileException(e) { | 37 bool checkLengthNonExistentFileException(e) { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 testReadAsLinesNonExistent(); | 455 testReadAsLinesNonExistent(); |
| 455 testWriteByteToReadOnlyFile(); | 456 testWriteByteToReadOnlyFile(); |
| 456 testWriteFromToReadOnlyFile(); | 457 testWriteFromToReadOnlyFile(); |
| 457 testTruncateReadOnlyFile(); | 458 testTruncateReadOnlyFile(); |
| 458 testOperateOnClosedFile(); | 459 testOperateOnClosedFile(); |
| 459 testRepeatedlyCloseFile(); | 460 testRepeatedlyCloseFile(); |
| 460 testRepeatedlyCloseFileSync(); | 461 testRepeatedlyCloseFileSync(); |
| 461 testReadSyncBigInt(); | 462 testReadSyncBigInt(); |
| 462 testReadSyncClosedFile(); | 463 testReadSyncClosedFile(); |
| 463 } | 464 } |
| OLD | NEW |