| Index: tests/standalone/io/file_test.dart
|
| diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
|
| index c241a5beb38e80175b88e9a2d5f50bf3bace271c..2fab82d7585082f3fbca4f1a772324c7d95b4b69 100644
|
| --- a/tests/standalone/io/file_test.dart
|
| +++ b/tests/standalone/io/file_test.dart
|
| @@ -716,6 +716,54 @@ class FileTest {
|
| Expect.isFalse(file.existsSync());
|
| }
|
|
|
| + static void testWriteFrom() async {
|
| + asyncTestStarted();
|
| + File file = new File(tempDirectory.path + "/out_write_from");
|
| +
|
| + var buffer = const [1, 2, 3];
|
| + var openedFile = await file.open(mode: WRITE);
|
| +
|
| + await openedFile.writeFrom(buffer);
|
| + var result = []..addAll(buffer);;
|
| +
|
| + write([start, end]) async {
|
| + await openedFile.writeFrom(buffer, start, end);
|
| + result.addAll(buffer.sublist(start, end));
|
| + }
|
| + await write(0, 3);
|
| + await write(0, 2);
|
| + await write(1, 2);
|
| + await write(1, 3);
|
| + await write(2, 3);
|
| +
|
| + var bytesFromFile = await file.readAsBytes();
|
| + Expect.listEquals(result, bytesFromFile);
|
| + asyncTestDone("testWriteFrom");
|
| + }
|
| +
|
| + static void testWriteFromSync() {
|
| + File file = new File(tempDirectory.path + "/out_write_from_sync");
|
| +
|
| + var buffer = const [1, 2, 3];
|
| + var openedFile = file.openSync(mode: WRITE);
|
| +
|
| + openedFile.writeFromSync(buffer);
|
| + var result = []..addAll(buffer);;
|
| +
|
| + write([start, end]) {
|
| + openedFile.writeFromSync(buffer, start, end);
|
| + result.addAll(buffer.sublist(start, end));
|
| + }
|
| + write(0, 3);
|
| + write(0, 2);
|
| + write(1, 2);
|
| + write(1, 3);
|
| + write(2, 3);
|
| +
|
| + var bytesFromFile = file.readAsBytesSync();
|
| + Expect.listEquals(result, bytesFromFile);
|
| + }
|
| +
|
| // Tests exception handling after file was closed.
|
| static void testCloseException() {
|
| bool exceptionCaught = false;
|
| @@ -1327,6 +1375,8 @@ class FileTest {
|
| testPosition();
|
| testTruncate();
|
| testTruncateSync();
|
| + testWriteFrom();
|
| + testWriteFromSync();
|
| testCloseException();
|
| testCloseExceptionStream();
|
| testBufferOutOfBoundsException();
|
|
|