| 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 "dart:convert"; | 7 import "dart:convert"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 | 9 |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| 11 import "package:expect/expect.dart"; | 11 import "package:expect/expect.dart"; |
| 12 | 12 |
| 13 Directory tempDir() { | 13 Directory tempDir() { |
| 14 return new Directory('').createTempSync(); | 14 return Directory.systemTemp.createTempSync('dart_file_error'); |
| 15 } | 15 } |
| 16 | 16 |
| 17 | 17 |
| 18 bool checkNonExistentFileException(e, str) { | 18 bool checkNonExistentFileException(e, str) { |
| 19 Expect.isTrue(e is FileException); | 19 Expect.isTrue(e is FileException); |
| 20 Expect.isTrue(e.osError != null); | 20 Expect.isTrue(e.osError != null); |
| 21 Expect.isTrue(e.toString().indexOf(str) != -1); | 21 Expect.isTrue(e.toString().indexOf(str) != -1); |
| 22 // File not not found has error code 2 on all supported platforms. | 22 // File not not found has error code 2 on all supported platforms. |
| 23 Expect.equals(2, e.osError.errorCode); | 23 Expect.equals(2, e.osError.errorCode); |
| 24 return true; | 24 return true; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 testReadAsLinesNonExistent(); | 430 testReadAsLinesNonExistent(); |
| 431 testWriteByteToReadOnlyFile(); | 431 testWriteByteToReadOnlyFile(); |
| 432 testWriteFromToReadOnlyFile(); | 432 testWriteFromToReadOnlyFile(); |
| 433 testTruncateReadOnlyFile(); | 433 testTruncateReadOnlyFile(); |
| 434 testOperateOnClosedFile(); | 434 testOperateOnClosedFile(); |
| 435 testRepeatedlyCloseFile(); | 435 testRepeatedlyCloseFile(); |
| 436 testRepeatedlyCloseFileSync(); | 436 testRepeatedlyCloseFileSync(); |
| 437 testReadSyncBigInt(); | 437 testReadSyncBigInt(); |
| 438 testReadSyncClosedFile(); | 438 testReadSyncClosedFile(); |
| 439 } | 439 } |
| OLD | NEW |