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:io"); | 7 #import("dart:io"); |
8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
9 | 9 |
10 class MyListOfOneElement implements List { | 10 class MyListOfOneElement implements List { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // Test reading all using read. | 109 // Test reading all using read. |
110 file = new File(inFilename); | 110 file = new File(inFilename); |
111 input = file.openInputStream(); | 111 input = file.openInputStream(); |
112 input.onData = () { | 112 input.onData = () { |
113 buffer1 = input.read(); | 113 buffer1 = input.read(); |
114 Expect.equals(42, buffer1.length); | 114 Expect.equals(42, buffer1.length); |
115 Expect.isTrue(input.closed); | 115 Expect.isTrue(input.closed); |
116 | 116 |
117 // Write the contents of the file just read into another file. | 117 // Write the contents of the file just read into another file. |
118 String outFilename = tempDirectory.path + "/out_read_write_stream"; | 118 String outFilename = |
| 119 tempDirectory.path.concat("/out_read_write_stream"); |
119 file = new File(outFilename); | 120 file = new File(outFilename); |
120 OutputStream output = file.openOutputStream(); | 121 OutputStream output = file.openOutputStream(); |
121 bool writeDone = output.writeFrom(buffer1, 0, 42); | 122 bool writeDone = output.writeFrom(buffer1, 0, 42); |
122 Expect.equals(false, writeDone); | 123 Expect.equals(false, writeDone); |
123 output.onNoPendingWrites = () { | 124 output.onNoPendingWrites = () { |
124 output.close(); | 125 output.close(); |
125 output.onClosed = () { | 126 output.onClosed = () { |
126 // Now read the contents of the file just written. | 127 // Now read the contents of the file just written. |
127 List<int> buffer2 = new List<int>(42); | 128 List<int> buffer2 = new List<int>(42); |
128 file = new File(outFilename); | 129 file = new File(outFilename); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 static void testReadWrite() { | 205 static void testReadWrite() { |
205 // Read a file. | 206 // Read a file. |
206 String inFilename = getFilename("tests/vm/data/fixed_length_file"); | 207 String inFilename = getFilename("tests/vm/data/fixed_length_file"); |
207 final File file = new File(inFilename); | 208 final File file = new File(inFilename); |
208 file.open(FileMode.READ).then((openedFile) { | 209 file.open(FileMode.READ).then((openedFile) { |
209 List<int> buffer1 = new List<int>(42); | 210 List<int> buffer1 = new List<int>(42); |
210 openedFile.readList(buffer1, 0, 42).then((bytes_read) { | 211 openedFile.readList(buffer1, 0, 42).then((bytes_read) { |
211 Expect.equals(42, bytes_read); | 212 Expect.equals(42, bytes_read); |
212 openedFile.close().then((ignore) { | 213 openedFile.close().then((ignore) { |
213 // Write the contents of the file just read into another file. | 214 // Write the contents of the file just read into another file. |
214 String outFilename = tempDirectory.path + "/out_read_write"; | 215 String outFilename = tempDirectory.path.concat("/out_read_write"); |
215 final File file2 = new File(outFilename); | 216 final File file2 = new File(outFilename); |
216 file2.create().then((ignore) { | 217 file2.create().then((ignore) { |
217 file2.fullPath().then((s) { | 218 file2.fullPath().then((s) { |
218 Expect.isTrue(new File(s).existsSync()); | 219 Expect.isTrue(new File(s).existsSync()); |
219 if (s[0] != '/' && s[0] != '\\' && s[1] != ':') { | 220 if (s[0] != '/' && s[0] != '\\' && s[1] != ':') { |
220 Expect.fail("Not a full path"); | 221 Expect.fail("Not a full path"); |
221 } | 222 } |
222 file2.open(FileMode.WRITE).then((openedFile2) { | 223 file2.open(FileMode.WRITE).then((openedFile2) { |
223 openedFile2.writeList(buffer1, 0, bytes_read).then((ignore) { | 224 openedFile2.writeList(buffer1, 0, bytes_read).then((ignore) { |
224 openedFile2.close().then((ignore) { | 225 openedFile2.close().then((ignore) { |
(...skipping 26 matching lines...) Expand all Loading... |
251 }); | 252 }); |
252 }); | 253 }); |
253 }); | 254 }); |
254 }); | 255 }); |
255 }); | 256 }); |
256 asyncTestStarted(); | 257 asyncTestStarted(); |
257 } | 258 } |
258 | 259 |
259 static void testWriteAppend() { | 260 static void testWriteAppend() { |
260 String content = "foobar"; | 261 String content = "foobar"; |
261 String filename = tempDirectory.path + "/write_append"; | 262 String filename = tempDirectory.path.concat("/write_append"); |
262 File file = new File(filename); | 263 File file = new File(filename); |
263 file.createSync(); | 264 file.createSync(); |
264 Expect.isTrue(new File(filename).existsSync()); | 265 Expect.isTrue(new File(filename).existsSync()); |
265 List<int> buffer = content.charCodes(); | 266 List<int> buffer = content.charCodes(); |
266 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 267 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
267 openedFile.writeListSync(buffer, 0, buffer.length); | 268 openedFile.writeListSync(buffer, 0, buffer.length); |
268 openedFile.closeSync(); | 269 openedFile.closeSync(); |
269 // Reopen the file in write mode to ensure that we overwrite the content. | 270 // Reopen the file in write mode to ensure that we overwrite the content. |
270 openedFile = (new File(filename)).openSync(FileMode.WRITE); | 271 openedFile = (new File(filename)).openSync(FileMode.WRITE); |
271 openedFile.writeListSync(buffer, 0, buffer.length); | 272 openedFile.writeListSync(buffer, 0, buffer.length); |
272 Expect.equals(content.length, openedFile.lengthSync()); | 273 Expect.equals(content.length, openedFile.lengthSync()); |
273 openedFile.closeSync(); | 274 openedFile.closeSync(); |
274 // Open the file in append mode and ensure that we do not overwrite | 275 // Open the file in append mode and ensure that we do not overwrite |
275 // the existing content. | 276 // the existing content. |
276 openedFile = (new File(filename)).openSync(FileMode.APPEND); | 277 openedFile = (new File(filename)).openSync(FileMode.APPEND); |
277 openedFile.writeListSync(buffer, 0, buffer.length); | 278 openedFile.writeListSync(buffer, 0, buffer.length); |
278 Expect.equals(content.length * 2, openedFile.lengthSync()); | 279 Expect.equals(content.length * 2, openedFile.lengthSync()); |
279 openedFile.closeSync(); | 280 openedFile.closeSync(); |
280 file.deleteSync(); | 281 file.deleteSync(); |
281 } | 282 } |
282 | 283 |
283 static void testOutputStreamWriteAppend() { | 284 static void testOutputStreamWriteAppend() { |
284 String content = "foobar"; | 285 String content = "foobar"; |
285 String filename = tempDirectory.path + "/outstream_write_append"; | 286 String filename = tempDirectory.path.concat("/outstream_write_append"); |
286 File file = new File(filename); | 287 File file = new File(filename); |
287 file.createSync(); | 288 file.createSync(); |
288 List<int> buffer = content.charCodes(); | 289 List<int> buffer = content.charCodes(); |
289 OutputStream outStream = file.openOutputStream(); | 290 OutputStream outStream = file.openOutputStream(); |
290 outStream.write(buffer); | 291 outStream.write(buffer); |
291 outStream.onNoPendingWrites = () { | 292 outStream.onNoPendingWrites = () { |
292 outStream.close(); | 293 outStream.close(); |
293 outStream.onClosed = () { | 294 outStream.onClosed = () { |
294 File file2 = new File(filename); | 295 File file2 = new File(filename); |
295 OutputStream appendingOutput = | 296 OutputStream appendingOutput = |
(...skipping 16 matching lines...) Expand all Loading... |
312 }; | 313 }; |
313 }; | 314 }; |
314 }; | 315 }; |
315 }; | 316 }; |
316 asyncTestStarted(); | 317 asyncTestStarted(); |
317 } | 318 } |
318 | 319 |
319 // Test for file read and write functionality. | 320 // Test for file read and write functionality. |
320 static void testOutputStreamWriteString() { | 321 static void testOutputStreamWriteString() { |
321 String content = "foobar"; | 322 String content = "foobar"; |
322 String filename = tempDirectory.path + "/outstream_write_string"; | 323 String filename = tempDirectory.path.concat("/outstream_write_string"); |
323 File file = new File(filename); | 324 File file = new File(filename); |
324 file.createSync(); | 325 file.createSync(); |
325 List<int> buffer = content.charCodes(); | 326 List<int> buffer = content.charCodes(); |
326 OutputStream outStream = file.openOutputStream(); | 327 OutputStream outStream = file.openOutputStream(); |
327 outStream.writeString("abcdABCD"); | 328 outStream.writeString("abcdABCD"); |
328 outStream.writeString("abcdABCD", Encoding.UTF_8); | 329 outStream.writeString("abcdABCD", Encoding.UTF_8); |
329 outStream.writeString("abcdABCD", Encoding.ISO_8859_1); | 330 outStream.writeString("abcdABCD", Encoding.ISO_8859_1); |
330 outStream.writeString("abcdABCD", Encoding.ASCII); | 331 outStream.writeString("abcdABCD", Encoding.ASCII); |
331 outStream.writeString("æøå", Encoding.UTF_8); | 332 outStream.writeString("æøå", Encoding.UTF_8); |
332 outStream.onNoPendingWrites = () { | 333 outStream.onNoPendingWrites = () { |
(...skipping 14 matching lines...) Expand all Loading... |
347 // Read a file. | 348 // Read a file. |
348 String inFilename = getFilename("tests/vm/data/fixed_length_file"); | 349 String inFilename = getFilename("tests/vm/data/fixed_length_file"); |
349 RandomAccessFile file = (new File(inFilename)).openSync(); | 350 RandomAccessFile file = (new File(inFilename)).openSync(); |
350 List<int> buffer1 = new List<int>(42); | 351 List<int> buffer1 = new List<int>(42); |
351 int bytes_read = 0; | 352 int bytes_read = 0; |
352 int bytes_written = 0; | 353 int bytes_written = 0; |
353 bytes_read = file.readListSync(buffer1, 0, 42); | 354 bytes_read = file.readListSync(buffer1, 0, 42); |
354 Expect.equals(42, bytes_read); | 355 Expect.equals(42, bytes_read); |
355 file.closeSync(); | 356 file.closeSync(); |
356 // Write the contents of the file just read into another file. | 357 // Write the contents of the file just read into another file. |
357 String outFilename = tempDirectory.path + "/out_read_write_sync"; | 358 String outFilename = tempDirectory.path.concat("/out_read_write_sync"); |
358 File outFile = new File(outFilename); | 359 File outFile = new File(outFilename); |
359 outFile.createSync(); | 360 outFile.createSync(); |
360 String path = outFile.fullPathSync(); | 361 String path = outFile.fullPathSync(); |
361 if (path[0] != '/' && path[0] != '\\' && path[1] != ':') { | 362 if (path[0] != '/' && path[0] != '\\' && path[1] != ':') { |
362 Expect.fail("Not a full path"); | 363 Expect.fail("Not a full path"); |
363 } | 364 } |
364 Expect.isTrue(new File(path).existsSync()); | 365 Expect.isTrue(new File(path).existsSync()); |
365 RandomAccessFile openedFile = outFile.openSync(FileMode.WRITE); | 366 RandomAccessFile openedFile = outFile.openSync(FileMode.WRITE); |
366 openedFile.writeListSync(buffer1, 0, bytes_read); | 367 openedFile.writeListSync(buffer1, 0, bytes_read); |
367 openedFile.closeSync(); | 368 openedFile.closeSync(); |
368 // Now read the contents of the file just written. | 369 // Now read the contents of the file just written. |
369 List<int> buffer2 = new List<int>(bytes_read); | 370 List<int> buffer2 = new List<int>(bytes_read); |
370 openedFile = (new File(outFilename)).openSync(); | 371 openedFile = (new File(outFilename)).openSync(); |
371 bytes_read = openedFile.readListSync(buffer2, 0, 42); | 372 bytes_read = openedFile.readListSync(buffer2, 0, 42); |
372 Expect.equals(42, bytes_read); | 373 Expect.equals(42, bytes_read); |
373 openedFile.closeSync(); | 374 openedFile.closeSync(); |
374 // Now compare the two buffers to check if they are identical. | 375 // Now compare the two buffers to check if they are identical. |
375 Expect.equals(buffer1.length, buffer2.length); | 376 Expect.equals(buffer1.length, buffer2.length); |
376 for (int i = 0; i < buffer1.length; i++) { | 377 for (int i = 0; i < buffer1.length; i++) { |
377 Expect.equals(buffer1[i], buffer2[i]); | 378 Expect.equals(buffer1[i], buffer2[i]); |
378 } | 379 } |
379 // Delete the output file. | 380 // Delete the output file. |
380 outFile.deleteSync(); | 381 outFile.deleteSync(); |
381 Expect.isFalse(outFile.existsSync()); | 382 Expect.isFalse(outFile.existsSync()); |
382 } | 383 } |
383 | 384 |
384 static void testReadEmptyFileSync() { | 385 static void testReadEmptyFileSync() { |
385 String fileName = tempDirectory.path + "/empty_file_sync"; | 386 String fileName = tempDirectory.path.concat("/empty_file_sync"); |
386 File file = new File(fileName); | 387 File file = new File(fileName); |
387 file.createSync(); | 388 file.createSync(); |
388 RandomAccessFile openedFile = file.openSync(); | 389 RandomAccessFile openedFile = file.openSync(); |
389 Expect.equals(-1, openedFile.readByteSync()); | 390 Expect.equals(-1, openedFile.readByteSync()); |
390 openedFile.closeSync(); | 391 openedFile.closeSync(); |
391 file.deleteSync(); | 392 file.deleteSync(); |
392 } | 393 } |
393 | 394 |
394 static void testReadEmptyFile() { | 395 static void testReadEmptyFile() { |
395 String fileName = tempDirectory.path + "/empty_file"; | 396 String fileName = tempDirectory.path.concat("/empty_file"); |
396 File file = new File(fileName); | 397 File file = new File(fileName); |
397 asyncTestStarted(); | 398 asyncTestStarted(); |
398 file.create().then((ignore) { | 399 file.create().then((ignore) { |
399 file.open(FileMode.READ).then((RandomAccessFile openedFile) { | 400 file.open(FileMode.READ).then((RandomAccessFile openedFile) { |
400 var readByteFuture = openedFile.readByte(); | 401 var readByteFuture = openedFile.readByte(); |
401 readByteFuture.then((int byte) { | 402 readByteFuture.then((int byte) { |
402 Expect.equals(-1, byte); | 403 Expect.equals(-1, byte); |
403 openedFile.close().then((ignore) { | 404 openedFile.close().then((ignore) { |
404 asyncTestDone("testReadEmptyFile"); | 405 asyncTestDone("testReadEmptyFile"); |
405 }); | 406 }); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 input.readListSync(buffer, 0, 12); | 570 input.readListSync(buffer, 0, 12); |
570 Expect.equals(12, input.positionSync()); | 571 Expect.equals(12, input.positionSync()); |
571 input.readListSync(buffer, 12, 6); | 572 input.readListSync(buffer, 12, 6); |
572 Expect.equals(18, input.positionSync()); | 573 Expect.equals(18, input.positionSync()); |
573 input.setPositionSync(8); | 574 input.setPositionSync(8); |
574 Expect.equals(8, input.positionSync()); | 575 Expect.equals(8, input.positionSync()); |
575 input.closeSync(); | 576 input.closeSync(); |
576 } | 577 } |
577 | 578 |
578 static void testTruncate() { | 579 static void testTruncate() { |
579 File file = new File(tempDirectory.path + "/out_truncate"); | 580 File file = new File(tempDirectory.path.concat("/out_truncate")); |
580 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; | 581 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; |
581 file.open(FileMode.WRITE).then((RandomAccessFile openedFile) { | 582 file.open(FileMode.WRITE).then((RandomAccessFile openedFile) { |
582 openedFile.writeList(buffer, 0, 10).then((ignore) { | 583 openedFile.writeList(buffer, 0, 10).then((ignore) { |
583 openedFile.length().then((length) { | 584 openedFile.length().then((length) { |
584 Expect.equals(10, length); | 585 Expect.equals(10, length); |
585 openedFile.truncate(5).then((ignore) { | 586 openedFile.truncate(5).then((ignore) { |
586 openedFile.length().then((length) { | 587 openedFile.length().then((length) { |
587 Expect.equals(5, length); | 588 Expect.equals(5, length); |
588 openedFile.close().then((ignore) { | 589 openedFile.close().then((ignore) { |
589 file.delete().then((ignore) { | 590 file.delete().then((ignore) { |
590 file.exists().then((exists) { | 591 file.exists().then((exists) { |
591 Expect.isFalse(exists); | 592 Expect.isFalse(exists); |
592 asyncTestDone("testTruncate"); | 593 asyncTestDone("testTruncate"); |
593 }); | 594 }); |
594 }); | 595 }); |
595 }); | 596 }); |
596 }); | 597 }); |
597 }); | 598 }); |
598 }); | 599 }); |
599 }); | 600 }); |
600 }); | 601 }); |
601 asyncTestStarted(); | 602 asyncTestStarted(); |
602 } | 603 } |
603 | 604 |
604 static void testTruncateSync() { | 605 static void testTruncateSync() { |
605 File file = new File(tempDirectory.path + "/out_truncate_sync"); | 606 File file = new File(tempDirectory.path.concat("/out_truncate_sync")); |
606 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; | 607 List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65]; |
607 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 608 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
608 openedFile.writeListSync(buffer, 0, 10); | 609 openedFile.writeListSync(buffer, 0, 10); |
609 Expect.equals(10, openedFile.lengthSync()); | 610 Expect.equals(10, openedFile.lengthSync()); |
610 openedFile.truncateSync(5); | 611 openedFile.truncateSync(5); |
611 Expect.equals(5, openedFile.lengthSync()); | 612 Expect.equals(5, openedFile.lengthSync()); |
612 openedFile.closeSync(); | 613 openedFile.closeSync(); |
613 file.deleteSync(); | 614 file.deleteSync(); |
614 Expect.isFalse(file.existsSync()); | 615 Expect.isFalse(file.existsSync()); |
615 } | 616 } |
616 | 617 |
617 // Tests exception handling after file was closed. | 618 // Tests exception handling after file was closed. |
618 static void testCloseException() { | 619 static void testCloseException() { |
619 bool exceptionCaught = false; | 620 bool exceptionCaught = false; |
620 bool wrongExceptionCaught = false; | 621 bool wrongExceptionCaught = false; |
621 File input = new File(tempDirectory.path + "/out_close_exception"); | 622 File input = new File(tempDirectory.path.concat("/out_close_exception")); |
622 RandomAccessFile openedFile = input.openSync(FileMode.WRITE); | 623 RandomAccessFile openedFile = input.openSync(FileMode.WRITE); |
623 openedFile.closeSync(); | 624 openedFile.closeSync(); |
624 try { | 625 try { |
625 openedFile.readByteSync(); | 626 openedFile.readByteSync(); |
626 } catch (FileIOException ex) { | 627 } catch (FileIOException ex) { |
627 exceptionCaught = true; | 628 exceptionCaught = true; |
628 } catch (Exception ex) { | 629 } catch (Exception ex) { |
629 wrongExceptionCaught = true; | 630 wrongExceptionCaught = true; |
630 } | 631 } |
631 Expect.equals(true, exceptionCaught); | 632 Expect.equals(true, exceptionCaught); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 } | 703 } |
703 Expect.equals(true, exceptionCaught); | 704 Expect.equals(true, exceptionCaught); |
704 Expect.equals(true, !wrongExceptionCaught); | 705 Expect.equals(true, !wrongExceptionCaught); |
705 input.deleteSync(); | 706 input.deleteSync(); |
706 } | 707 } |
707 | 708 |
708 // Tests stream exception handling after file was closed. | 709 // Tests stream exception handling after file was closed. |
709 static void testCloseExceptionStream() { | 710 static void testCloseExceptionStream() { |
710 asyncTestStarted(); | 711 asyncTestStarted(); |
711 List<int> buffer = new List<int>(42); | 712 List<int> buffer = new List<int>(42); |
712 File file = new File(tempDirectory.path + "/out_close_exception_stream"); | 713 File file = |
| 714 new File(tempDirectory.path.concat("/out_close_exception_stream")); |
713 file.createSync(); | 715 file.createSync(); |
714 InputStream input = file.openInputStream(); | 716 InputStream input = file.openInputStream(); |
715 input.onClosed = () { | 717 input.onClosed = () { |
716 Expect.isTrue(input.closed); | 718 Expect.isTrue(input.closed); |
717 Expect.isNull(input.readInto(buffer, 0, 12)); | 719 Expect.isNull(input.readInto(buffer, 0, 12)); |
718 OutputStream output = file.openOutputStream(); | 720 OutputStream output = file.openOutputStream(); |
719 output.close(); | 721 output.close(); |
720 Expect.throws(() => output.writeFrom(buffer, 0, 12)); | 722 Expect.throws(() => output.writeFrom(buffer, 0, 12)); |
721 output.onClosed = () { | 723 output.onClosed = () { |
722 file.deleteSync(); | 724 file.deleteSync(); |
723 asyncTestDone("testCloseExceptionStream"); | 725 asyncTestDone("testCloseExceptionStream"); |
724 }; | 726 }; |
725 }; | 727 }; |
726 } | 728 } |
727 | 729 |
728 // Tests buffer out of bounds exception. | 730 // Tests buffer out of bounds exception. |
729 static void testBufferOutOfBoundsException() { | 731 static void testBufferOutOfBoundsException() { |
730 bool exceptionCaught = false; | 732 bool exceptionCaught = false; |
731 bool wrongExceptionCaught = false; | 733 bool wrongExceptionCaught = false; |
732 File file = new File(tempDirectory.path + "/out_buffer_out_of_bounds"); | 734 File file = |
| 735 new File(tempDirectory.path.concat("/out_buffer_out_of_bounds")); |
733 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); | 736 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); |
734 try { | 737 try { |
735 List<int> buffer = new List<int>(10); | 738 List<int> buffer = new List<int>(10); |
736 openedFile.readListSync(buffer, 0, 12); | 739 openedFile.readListSync(buffer, 0, 12); |
737 } catch (IndexOutOfRangeException ex) { | 740 } catch (IndexOutOfRangeException ex) { |
738 exceptionCaught = true; | 741 exceptionCaught = true; |
739 } catch (Exception ex) { | 742 } catch (Exception ex) { |
740 wrongExceptionCaught = true; | 743 wrongExceptionCaught = true; |
741 } | 744 } |
742 Expect.equals(true, exceptionCaught); | 745 Expect.equals(true, exceptionCaught); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 openedFile.writeStringSync("asdf"); | 1013 openedFile.writeStringSync("asdf"); |
1011 Expect.equals(8, openedFile.lengthSync()); | 1014 Expect.equals(8, openedFile.lengthSync()); |
1012 openedFile.closeSync(); | 1015 openedFile.closeSync(); |
1013 file.deleteSync(); | 1016 file.deleteSync(); |
1014 Expect.isFalse(file.existsSync()); | 1017 Expect.isFalse(file.existsSync()); |
1015 } | 1018 } |
1016 | 1019 |
1017 // Helper method to be able to run the test from the runtime | 1020 // Helper method to be able to run the test from the runtime |
1018 // directory, or the top directory. | 1021 // directory, or the top directory. |
1019 static String getFilename(String path) => | 1022 static String getFilename(String path) => |
1020 new File(path).existsSync() ? path : 'runtime/' + path; | 1023 new File(path).existsSync() ? path : 'runtime/$path'; |
1021 | 1024 |
1022 static String getDataFilename(String path) => | 1025 static String getDataFilename(String path) => |
1023 new File(path).existsSync() ? path : '../' + path; | 1026 new File(path).existsSync() ? path : '../$path'; |
1024 | 1027 |
1025 // Main test entrypoint. | 1028 // Main test entrypoint. |
1026 static testMain() { | 1029 static testMain() { |
1027 port = new ReceivePort(); | 1030 port = new ReceivePort(); |
1028 testRead(); | 1031 testRead(); |
1029 testReadSync(); | 1032 testReadSync(); |
1030 testReadStream(); | 1033 testReadStream(); |
1031 testLength(); | 1034 testLength(); |
1032 testLengthSync(); | 1035 testLengthSync(); |
1033 testPosition(); | 1036 testPosition(); |
(...skipping 27 matching lines...) Expand all Loading... |
1061 testWriteVariousLists(); | 1064 testWriteVariousLists(); |
1062 testDirectory(); | 1065 testDirectory(); |
1063 testDirectorySync(); | 1066 testDirectorySync(); |
1064 }); | 1067 }); |
1065 } | 1068 } |
1066 } | 1069 } |
1067 | 1070 |
1068 main() { | 1071 main() { |
1069 FileTest.testMain(); | 1072 FileTest.testMain(); |
1070 } | 1073 } |
OLD | NEW |