| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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:io"); | 7 #import("dart:io"); |
| 8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 9 | 9 |
| 10 Directory tempDir() { | 10 Directory tempDir() { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 void testReadAsTextNonExistent() { | 266 void testReadAsTextNonExistent() { |
| 267 Directory temp = tempDir(); | 267 Directory temp = tempDir(); |
| 268 ReceivePort p = new ReceivePort(); | 268 ReceivePort p = new ReceivePort(); |
| 269 p.receive((x, y) { | 269 p.receive((x, y) { |
| 270 p.close(); | 270 p.close(); |
| 271 temp.deleteSync(recursive: true); | 271 temp.deleteSync(recursive: true); |
| 272 }); | 272 }); |
| 273 var file = new File("${temp.path}/nonExistentFile4"); | 273 var file = new File("${temp.path}/nonExistentFile4"); |
| 274 | 274 |
| 275 // Non-existing file should throw exception. | 275 // Non-existing file should throw exception. |
| 276 Expect.throws(() => file.readAsTextSync(), | 276 Expect.throws(() => file.readAsStringSync(), |
| 277 (e) => checkOpenNonExistentFileException(e)); | 277 (e) => checkOpenNonExistentFileException(e)); |
| 278 | 278 |
| 279 var readAsTextFuture = file.readAsText(Encoding.ASCII); | 279 var readAsStringFuture = file.readAsString(Encoding.ASCII); |
| 280 readAsTextFuture.then((data) => Expect.fail("Unreachable code")); | 280 readAsStringFuture.then((data) => Expect.fail("Unreachable code")); |
| 281 readAsTextFuture.handleException((e) { | 281 readAsStringFuture.handleException((e) { |
| 282 checkOpenNonExistentFileException(e); | 282 checkOpenNonExistentFileException(e); |
| 283 p.toSendPort().send(null); | 283 p.toSendPort().send(null); |
| 284 return true; | 284 return true; |
| 285 }); | 285 }); |
| 286 } | 286 } |
| 287 | 287 |
| 288 testReadAsLinesNonExistent() { | 288 testReadAsLinesNonExistent() { |
| 289 Directory temp = tempDir(); | 289 Directory temp = tempDir(); |
| 290 ReceivePort p = new ReceivePort(); | 290 ReceivePort p = new ReceivePort(); |
| 291 p.receive((x, y) { | 291 p.receive((x, y) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 testReadAsBytesNonExistent(); | 510 testReadAsBytesNonExistent(); |
| 511 testReadAsTextNonExistent(); | 511 testReadAsTextNonExistent(); |
| 512 testReadAsLinesNonExistent(); | 512 testReadAsLinesNonExistent(); |
| 513 testWriteByteToReadOnlyFile(); | 513 testWriteByteToReadOnlyFile(); |
| 514 testWriteListToReadOnlyFile(); | 514 testWriteListToReadOnlyFile(); |
| 515 testTruncateReadOnlyFile(); | 515 testTruncateReadOnlyFile(); |
| 516 testOperateOnClosedFile(); | 516 testOperateOnClosedFile(); |
| 517 testRepeatedlyCloseFile(); | 517 testRepeatedlyCloseFile(); |
| 518 testRepeatedlyCloseFileSync(); | 518 testRepeatedlyCloseFileSync(); |
| 519 } | 519 } |
| OLD | NEW |