| 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 file I/O. | 5 // Dart test program for testing file I/O. |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 var file1 = new File(inFilename); | 81 var file1 = new File(inFilename); |
| 82 List<int> buffer = new List<int>(); | 82 List<int> buffer = new List<int>(); |
| 83 file1.openRead().listen( | 83 file1.openRead().listen( |
| 84 (d) { | 84 (d) { |
| 85 buffer.addAll(d); | 85 buffer.addAll(d); |
| 86 }, | 86 }, |
| 87 onDone: () { | 87 onDone: () { |
| 88 Expect.equals(42, buffer.length); | 88 Expect.equals(42, buffer.length); |
| 89 // Write the contents of the file just read into another file. | 89 // Write the contents of the file just read into another file. |
| 90 String outFilename = | 90 String outFilename = |
| 91 tempDirectory.path.concat("/out_read_write_stream"); | 91 tempDirectory.path + "/out_read_write_stream"; |
| 92 var file2 = new File(outFilename); | 92 var file2 = new File(outFilename); |
| 93 var output = file2.openWrite(); | 93 var output = file2.openWrite(); |
| 94 output.add(buffer); | 94 output.add(buffer); |
| 95 output.close(); | 95 output.close(); |
| 96 output.done.then((_) { | 96 output.done.then((_) { |
| 97 // Now read the contents of the file just written. | 97 // Now read the contents of the file just written. |
| 98 List<int> buffer2 = new List<int>(); | 98 List<int> buffer2 = new List<int>(); |
| 99 new File(outFilename).openRead().listen( | 99 new File(outFilename).openRead().listen( |
| 100 (d) { | 100 (d) { |
| 101 buffer2.addAll(d); | 101 buffer2.addAll(d); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 119 // Test for file stream buffered handling of large files. | 119 // Test for file stream buffered handling of large files. |
| 120 static void testReadWriteStreamLargeFile() { | 120 static void testReadWriteStreamLargeFile() { |
| 121 asyncTestStarted(); | 121 asyncTestStarted(); |
| 122 | 122 |
| 123 // Create the test data - arbitrary binary data. | 123 // Create the test data - arbitrary binary data. |
| 124 List<int> buffer = new List<int>(100000); | 124 List<int> buffer = new List<int>(100000); |
| 125 for (var i = 0; i < buffer.length; ++i) { | 125 for (var i = 0; i < buffer.length; ++i) { |
| 126 buffer[i] = i % 256; | 126 buffer[i] = i % 256; |
| 127 } | 127 } |
| 128 String filename = | 128 String filename = |
| 129 tempDirectory.path.concat("/out_read_write_stream_large_file"); | 129 tempDirectory.path + "/out_read_write_stream_large_file"; |
| 130 File file = new File(filename); | 130 File file = new File(filename); |
| 131 IOSink output = file.openWrite(); | 131 IOSink output = file.openWrite(); |
| 132 output.add(buffer); | 132 output.add(buffer); |
| 133 output.add(buffer); | 133 output.add(buffer); |
| 134 output.close(); | 134 output.close(); |
| 135 output.done.then((_) { | 135 output.done.then((_) { |
| 136 Stream input = file.openRead(); | 136 Stream input = file.openRead(); |
| 137 int position = 0; | 137 int position = 0; |
| 138 final int expectedLength = 200000; | 138 final int expectedLength = 200000; |
| 139 // Start an independent asynchronous check on the length. | 139 // Start an independent asynchronous check on the length. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 static void testReadWrite() { | 261 static void testReadWrite() { |
| 262 // Read a file. | 262 // Read a file. |
| 263 String inFilename = getFilename("tests/vm/data/fixed_length_file"); | 263 String inFilename = getFilename("tests/vm/data/fixed_length_file"); |
| 264 final File file = new File(inFilename); | 264 final File file = new File(inFilename); |
| 265 file.open(FileMode.READ).then((openedFile) { | 265 file.open(FileMode.READ).then((openedFile) { |
| 266 List<int> buffer1 = new List<int>(42); | 266 List<int> buffer1 = new List<int>(42); |
| 267 openedFile.readList(buffer1, 0, 42).then((bytes_read) { | 267 openedFile.readList(buffer1, 0, 42).then((bytes_read) { |
| 268 Expect.equals(42, bytes_read); | 268 Expect.equals(42, bytes_read); |
| 269 openedFile.close().then((ignore) { | 269 openedFile.close().then((ignore) { |
| 270 // Write the contents of the file just read into another file. | 270 // Write the contents of the file just read into another file. |
| 271 String outFilename = tempDirectory.path.concat("/out_read_write"); | 271 String outFilename = tempDirectory.path + "/out_read_write"; |
| 272 final File file2 = new File(outFilename); | 272 final File file2 = new File(outFilename); |
| 273 file2.create().then((ignore) { | 273 file2.create().then((ignore) { |
| 274 file2.fullPath().then((s) { | 274 file2.fullPath().then((s) { |
| 275 Expect.isTrue(new File(s).existsSync()); | 275 Expect.isTrue(new File(s).existsSync()); |
| 276 if (s[0] != '/' && s[0] != '\\' && s[1] != ':') { | 276 if (s[0] != '/' && s[0] != '\\' && s[1] != ':') { |
| 277 Expect.fail("Not a full path"); | 277 Expect.fail("Not a full path"); |
| 278 } | 278 } |
| 279 file2.open(FileMode.WRITE).then((openedFile2) { | 279 file2.open(FileMode.WRITE).then((openedFile2) { |
| 280 openedFile2.writeList(buffer1, 0, bytes_read).then((ignore) { | 280 openedFile2.writeList(buffer1, 0, bytes_read).then((ignore) { |
| 281 openedFile2.close().then((ignore) { | 281 openedFile2.close().then((ignore) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 308 }); | 308 }); |
| 309 }); | 309 }); |
| 310 }); | 310 }); |
| 311 }); | 311 }); |
| 312 }); | 312 }); |
| 313 asyncTestStarted(); | 313 asyncTestStarted(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 static void testWriteAppend() { | 316 static void testWriteAppend() { |
| 317 String content = "foobar"; | 317 String content = "foobar"; |
| 318 String filename = tempDirectory.path.concat("/write_append"); | 318 String filename = tempDirectory.path + "/write_append"; |
| 319 File file = new File(filename); | 319 File file = new File(filename); |
| 320 file.createSync(); | 320 file.createSync(); |
| 321 Expect.isTrue(new File(filename).existsSync()); | 321 Expect.isTrue(new File(filename).existsSync()); |
| 322 List<int> buffer = content.codeUnits; | 322 List<int> buffer = content.codeUnits; |
| 323 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 323 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
| 324 openedFile.writeListSync(buffer, 0, buffer.length); | 324 openedFile.writeListSync(buffer, 0, buffer.length); |
| 325 openedFile.closeSync(); | 325 openedFile.closeSync(); |
| 326 // Reopen the file in write mode to ensure that we overwrite the content. | 326 // Reopen the file in write mode to ensure that we overwrite the content. |
| 327 openedFile = (new File(filename)).openSync(FileMode.WRITE); | 327 openedFile = (new File(filename)).openSync(FileMode.WRITE); |
| 328 openedFile.writeListSync(buffer, 0, buffer.length); | 328 openedFile.writeListSync(buffer, 0, buffer.length); |
| 329 Expect.equals(content.length, openedFile.lengthSync()); | 329 Expect.equals(content.length, openedFile.lengthSync()); |
| 330 openedFile.closeSync(); | 330 openedFile.closeSync(); |
| 331 // Open the file in append mode and ensure that we do not overwrite | 331 // Open the file in append mode and ensure that we do not overwrite |
| 332 // the existing content. | 332 // the existing content. |
| 333 openedFile = (new File(filename)).openSync(FileMode.APPEND); | 333 openedFile = (new File(filename)).openSync(FileMode.APPEND); |
| 334 openedFile.writeListSync(buffer, 0, buffer.length); | 334 openedFile.writeListSync(buffer, 0, buffer.length); |
| 335 Expect.equals(content.length * 2, openedFile.lengthSync()); | 335 Expect.equals(content.length * 2, openedFile.lengthSync()); |
| 336 openedFile.closeSync(); | 336 openedFile.closeSync(); |
| 337 file.deleteSync(); | 337 file.deleteSync(); |
| 338 } | 338 } |
| 339 | 339 |
| 340 static void testOutputStreamWriteAppend() { | 340 static void testOutputStreamWriteAppend() { |
| 341 String content = "foobar"; | 341 String content = "foobar"; |
| 342 String filename = tempDirectory.path.concat("/outstream_write_append"); | 342 String filename = tempDirectory.path + "/outstream_write_append"; |
| 343 File file = new File(filename); | 343 File file = new File(filename); |
| 344 file.createSync(); | 344 file.createSync(); |
| 345 List<int> buffer = content.codeUnits; | 345 List<int> buffer = content.codeUnits; |
| 346 var output = file.openWrite(); | 346 var output = file.openWrite(); |
| 347 output.add(buffer); | 347 output.add(buffer); |
| 348 output.close(); | 348 output.close(); |
| 349 output.done.then((_) { | 349 output.done.then((_) { |
| 350 File file2 = new File(filename); | 350 File file2 = new File(filename); |
| 351 var appendingOutput = file2.openWrite(FileMode.APPEND); | 351 var appendingOutput = file2.openWrite(FileMode.APPEND); |
| 352 appendingOutput.add(buffer); | 352 appendingOutput.add(buffer); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 364 }); | 364 }); |
| 365 }); | 365 }); |
| 366 }); | 366 }); |
| 367 }); | 367 }); |
| 368 asyncTestStarted(); | 368 asyncTestStarted(); |
| 369 } | 369 } |
| 370 | 370 |
| 371 // Test for file read and write functionality. | 371 // Test for file read and write functionality. |
| 372 static void testOutputStreamWriteString() { | 372 static void testOutputStreamWriteString() { |
| 373 String content = "foobar"; | 373 String content = "foobar"; |
| 374 String filename = tempDirectory.path.concat("/outstream_write_string"); | 374 String filename = tempDirectory.path + "/outstream_write_string"; |
| 375 File file = new File(filename); | 375 File file = new File(filename); |
| 376 file.createSync(); | 376 file.createSync(); |
| 377 List<int> buffer = content.codeUnits; | 377 List<int> buffer = content.codeUnits; |
| 378 var output = file.openWrite(); | 378 var output = file.openWrite(); |
| 379 output.addString("abcdABCD"); | 379 output.addString("abcdABCD"); |
| 380 output.addString("abcdABCD", Encoding.UTF_8); | 380 output.addString("abcdABCD", Encoding.UTF_8); |
| 381 output.addString("abcdABCD", Encoding.ISO_8859_1); | 381 output.addString("abcdABCD", Encoding.ISO_8859_1); |
| 382 output.addString("abcdABCD", Encoding.ASCII); | 382 output.addString("abcdABCD", Encoding.ASCII); |
| 383 output.addString("æøå", Encoding.UTF_8); | 383 output.addString("æøå", Encoding.UTF_8); |
| 384 output.close(); | 384 output.close(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 397 // Read a file. | 397 // Read a file. |
| 398 String inFilename = getFilename("tests/vm/data/fixed_length_file"); | 398 String inFilename = getFilename("tests/vm/data/fixed_length_file"); |
| 399 RandomAccessFile file = (new File(inFilename)).openSync(); | 399 RandomAccessFile file = (new File(inFilename)).openSync(); |
| 400 List<int> buffer1 = new List<int>(42); | 400 List<int> buffer1 = new List<int>(42); |
| 401 int bytes_read = 0; | 401 int bytes_read = 0; |
| 402 int bytes_written = 0; | 402 int bytes_written = 0; |
| 403 bytes_read = file.readListSync(buffer1, 0, 42); | 403 bytes_read = file.readListSync(buffer1, 0, 42); |
| 404 Expect.equals(42, bytes_read); | 404 Expect.equals(42, bytes_read); |
| 405 file.closeSync(); | 405 file.closeSync(); |
| 406 // Write the contents of the file just read into another file. | 406 // Write the contents of the file just read into another file. |
| 407 String outFilename = tempDirectory.path.concat("/out_read_write_sync"); | 407 String outFilename = tempDirectory.path + "/out_read_write_sync"; |
| 408 File outFile = new File(outFilename); | 408 File outFile = new File(outFilename); |
| 409 outFile.createSync(); | 409 outFile.createSync(); |
| 410 String path = outFile.fullPathSync(); | 410 String path = outFile.fullPathSync(); |
| 411 if (path[0] != '/' && path[0] != '\\' && path[1] != ':') { | 411 if (path[0] != '/' && path[0] != '\\' && path[1] != ':') { |
| 412 Expect.fail("Not a full path"); | 412 Expect.fail("Not a full path"); |
| 413 } | 413 } |
| 414 Expect.isTrue(new File(path).existsSync()); | 414 Expect.isTrue(new File(path).existsSync()); |
| 415 RandomAccessFile openedFile = outFile.openSync(FileMode.WRITE); | 415 RandomAccessFile openedFile = outFile.openSync(FileMode.WRITE); |
| 416 openedFile.writeListSync(buffer1, 0, bytes_read); | 416 openedFile.writeListSync(buffer1, 0, bytes_read); |
| 417 openedFile.closeSync(); | 417 openedFile.closeSync(); |
| 418 // Now read the contents of the file just written. | 418 // Now read the contents of the file just written. |
| 419 List<int> buffer2 = new List<int>(bytes_read); | 419 List<int> buffer2 = new List<int>(bytes_read); |
| 420 openedFile = (new File(outFilename)).openSync(); | 420 openedFile = (new File(outFilename)).openSync(); |
| 421 bytes_read = openedFile.readListSync(buffer2, 0, 42); | 421 bytes_read = openedFile.readListSync(buffer2, 0, 42); |
| 422 Expect.equals(42, bytes_read); | 422 Expect.equals(42, bytes_read); |
| 423 openedFile.closeSync(); | 423 openedFile.closeSync(); |
| 424 // Now compare the two buffers to check if they are identical. | 424 // Now compare the two buffers to check if they are identical. |
| 425 Expect.equals(buffer1.length, buffer2.length); | 425 Expect.equals(buffer1.length, buffer2.length); |
| 426 for (int i = 0; i < buffer1.length; i++) { | 426 for (int i = 0; i < buffer1.length; i++) { |
| 427 Expect.equals(buffer1[i], buffer2[i]); | 427 Expect.equals(buffer1[i], buffer2[i]); |
| 428 } | 428 } |
| 429 // Delete the output file. | 429 // Delete the output file. |
| 430 outFile.deleteSync(); | 430 outFile.deleteSync(); |
| 431 Expect.isFalse(outFile.existsSync()); | 431 Expect.isFalse(outFile.existsSync()); |
| 432 } | 432 } |
| 433 | 433 |
| 434 static void testReadEmptyFileSync() { | 434 static void testReadEmptyFileSync() { |
| 435 String fileName = tempDirectory.path.concat("/empty_file_sync"); | 435 String fileName = tempDirectory.path + "/empty_file_sync"; |
| 436 File file = new File(fileName); | 436 File file = new File(fileName); |
| 437 file.createSync(); | 437 file.createSync(); |
| 438 RandomAccessFile openedFile = file.openSync(); | 438 RandomAccessFile openedFile = file.openSync(); |
| 439 Expect.equals(-1, openedFile.readByteSync()); | 439 Expect.equals(-1, openedFile.readByteSync()); |
| 440 openedFile.closeSync(); | 440 openedFile.closeSync(); |
| 441 file.deleteSync(); | 441 file.deleteSync(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 static void testReadEmptyFile() { | 444 static void testReadEmptyFile() { |
| 445 String fileName = tempDirectory.path.concat("/empty_file"); | 445 String fileName = tempDirectory.path + "/empty_file"; |
| 446 File file = new File(fileName); | 446 File file = new File(fileName); |
| 447 asyncTestStarted(); | 447 asyncTestStarted(); |
| 448 file.create().then((ignore) { | 448 file.create().then((ignore) { |
| 449 file.open(FileMode.READ).then((RandomAccessFile openedFile) { | 449 file.open(FileMode.READ).then((RandomAccessFile openedFile) { |
| 450 var readByteFuture = openedFile.readByte(); | 450 var readByteFuture = openedFile.readByte(); |
| 451 readByteFuture.then((int byte) { | 451 readByteFuture.then((int byte) { |
| 452 Expect.equals(-1, byte); | 452 Expect.equals(-1, byte); |
| 453 openedFile.close().then((ignore) { | 453 openedFile.close().then((ignore) { |
| 454 asyncTestDone("testReadEmptyFile"); | 454 asyncTestDone("testReadEmptyFile"); |
| 455 }); | 455 }); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 input.readListSync(buffer, 0, 12); | 616 input.readListSync(buffer, 0, 12); |
| 617 Expect.equals(12, input.positionSync()); | 617 Expect.equals(12, input.positionSync()); |
| 618 input.readListSync(buffer, 12, 6); | 618 input.readListSync(buffer, 12, 6); |
| 619 Expect.equals(18, input.positionSync()); | 619 Expect.equals(18, input.positionSync()); |
| 620 input.setPositionSync(8); | 620 input.setPositionSync(8); |
| 621 Expect.equals(8, input.positionSync()); | 621 Expect.equals(8, input.positionSync()); |
| 622 input.closeSync(); | 622 input.closeSync(); |
| 623 } | 623 } |
| 624 | 624 |
| 625 static void testTruncate() { | 625 static void testTruncate() { |
| 626 File file = new File(tempDirectory.path.concat("/out_truncate")); | 626 File file = new File(tempDirectory.path + "/out_truncate"); |
| 627 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; | 627 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; |
| 628 file.open(FileMode.WRITE).then((RandomAccessFile openedFile) { | 628 file.open(FileMode.WRITE).then((RandomAccessFile openedFile) { |
| 629 openedFile.writeList(buffer, 0, 10).then((ignore) { | 629 openedFile.writeList(buffer, 0, 10).then((ignore) { |
| 630 openedFile.length().then((length) { | 630 openedFile.length().then((length) { |
| 631 Expect.equals(10, length); | 631 Expect.equals(10, length); |
| 632 openedFile.truncate(5).then((ignore) { | 632 openedFile.truncate(5).then((ignore) { |
| 633 openedFile.length().then((length) { | 633 openedFile.length().then((length) { |
| 634 Expect.equals(5, length); | 634 Expect.equals(5, length); |
| 635 openedFile.close().then((ignore) { | 635 openedFile.close().then((ignore) { |
| 636 file.delete().then((ignore) { | 636 file.delete().then((ignore) { |
| 637 file.exists().then((exists) { | 637 file.exists().then((exists) { |
| 638 Expect.isFalse(exists); | 638 Expect.isFalse(exists); |
| 639 asyncTestDone("testTruncate"); | 639 asyncTestDone("testTruncate"); |
| 640 }); | 640 }); |
| 641 }); | 641 }); |
| 642 }); | 642 }); |
| 643 }); | 643 }); |
| 644 }); | 644 }); |
| 645 }); | 645 }); |
| 646 }); | 646 }); |
| 647 }); | 647 }); |
| 648 asyncTestStarted(); | 648 asyncTestStarted(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 static void testTruncateSync() { | 651 static void testTruncateSync() { |
| 652 File file = new File(tempDirectory.path.concat("/out_truncate_sync")); | 652 File file = new File(tempDirectory.path + "/out_truncate_sync"); |
| 653 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; | 653 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; |
| 654 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 654 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
| 655 openedFile.writeListSync(buffer, 0, 10); | 655 openedFile.writeListSync(buffer, 0, 10); |
| 656 Expect.equals(10, openedFile.lengthSync()); | 656 Expect.equals(10, openedFile.lengthSync()); |
| 657 openedFile.truncateSync(5); | 657 openedFile.truncateSync(5); |
| 658 Expect.equals(5, openedFile.lengthSync()); | 658 Expect.equals(5, openedFile.lengthSync()); |
| 659 openedFile.closeSync(); | 659 openedFile.closeSync(); |
| 660 file.deleteSync(); | 660 file.deleteSync(); |
| 661 Expect.isFalse(file.existsSync()); | 661 Expect.isFalse(file.existsSync()); |
| 662 } | 662 } |
| 663 | 663 |
| 664 // Tests exception handling after file was closed. | 664 // Tests exception handling after file was closed. |
| 665 static void testCloseException() { | 665 static void testCloseException() { |
| 666 bool exceptionCaught = false; | 666 bool exceptionCaught = false; |
| 667 bool wrongExceptionCaught = false; | 667 bool wrongExceptionCaught = false; |
| 668 File input = new File(tempDirectory.path.concat("/out_close_exception")); | 668 File input = new File(tempDirectory.path + "/out_close_exception"); |
| 669 RandomAccessFile openedFile = input.openSync(FileMode.WRITE); | 669 RandomAccessFile openedFile = input.openSync(FileMode.WRITE); |
| 670 openedFile.closeSync(); | 670 openedFile.closeSync(); |
| 671 try { | 671 try { |
| 672 openedFile.readByteSync(); | 672 openedFile.readByteSync(); |
| 673 } on FileIOException catch (ex) { | 673 } on FileIOException catch (ex) { |
| 674 exceptionCaught = true; | 674 exceptionCaught = true; |
| 675 } on Exception catch (ex) { | 675 } on Exception catch (ex) { |
| 676 wrongExceptionCaught = true; | 676 wrongExceptionCaught = true; |
| 677 } | 677 } |
| 678 Expect.equals(true, exceptionCaught); | 678 Expect.equals(true, exceptionCaught); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 Expect.equals(true, exceptionCaught); | 750 Expect.equals(true, exceptionCaught); |
| 751 Expect.equals(true, !wrongExceptionCaught); | 751 Expect.equals(true, !wrongExceptionCaught); |
| 752 input.deleteSync(); | 752 input.deleteSync(); |
| 753 } | 753 } |
| 754 | 754 |
| 755 // Tests stream exception handling after file was closed. | 755 // Tests stream exception handling after file was closed. |
| 756 static void testCloseExceptionStream() { | 756 static void testCloseExceptionStream() { |
| 757 asyncTestStarted(); | 757 asyncTestStarted(); |
| 758 List<int> buffer = new List<int>(42); | 758 List<int> buffer = new List<int>(42); |
| 759 File file = | 759 File file = |
| 760 new File(tempDirectory.path.concat("/out_close_exception_stream")); | 760 new File(tempDirectory.path + "/out_close_exception_stream"); |
| 761 file.createSync(); | 761 file.createSync(); |
| 762 var output = file.openWrite(); | 762 var output = file.openWrite(); |
| 763 output.close(); | 763 output.close(); |
| 764 Expect.throws(() => output.add(buffer)); | 764 Expect.throws(() => output.add(buffer)); |
| 765 output.done.then((_) { | 765 output.done.then((_) { |
| 766 file.deleteSync(); | 766 file.deleteSync(); |
| 767 asyncTestDone("testCloseExceptionStream"); | 767 asyncTestDone("testCloseExceptionStream"); |
| 768 }); | 768 }); |
| 769 } | 769 } |
| 770 | 770 |
| 771 // Tests buffer out of bounds exception. | 771 // Tests buffer out of bounds exception. |
| 772 static void testBufferOutOfBoundsException() { | 772 static void testBufferOutOfBoundsException() { |
| 773 bool exceptionCaught = false; | 773 bool exceptionCaught = false; |
| 774 bool wrongExceptionCaught = false; | 774 bool wrongExceptionCaught = false; |
| 775 File file = | 775 File file = |
| 776 new File(tempDirectory.path.concat("/out_buffer_out_of_bounds")); | 776 new File(tempDirectory.path + "/out_buffer_out_of_bounds"); |
| 777 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 777 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
| 778 try { | 778 try { |
| 779 List<int> buffer = new List<int>(10); | 779 List<int> buffer = new List<int>(10); |
| 780 openedFile.readListSync(buffer, 0, 12); | 780 openedFile.readListSync(buffer, 0, 12); |
| 781 } on RangeError catch (ex) { | 781 } on RangeError catch (ex) { |
| 782 exceptionCaught = true; | 782 exceptionCaught = true; |
| 783 } on Exception catch (ex) { | 783 } on Exception catch (ex) { |
| 784 wrongExceptionCaught = true; | 784 wrongExceptionCaught = true; |
| 785 } | 785 } |
| 786 Expect.equals(true, exceptionCaught); | 786 Expect.equals(true, exceptionCaught); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 testDirectorySync(); | 1232 testDirectorySync(); |
| 1233 testWriteStringUtf8(); | 1233 testWriteStringUtf8(); |
| 1234 testWriteStringUtf8Sync(); | 1234 testWriteStringUtf8Sync(); |
| 1235 }); | 1235 }); |
| 1236 } | 1236 } |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 main() { | 1239 main() { |
| 1240 FileTest.testMain(); | 1240 FileTest.testMain(); |
| 1241 } | 1241 } |
| OLD | NEW |