| Index: tests/standalone/io/file_test.dart
|
| diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
|
| index 122a4cdcd0505320ae4fd1308dbcce1167a5002f..1583d7f38fe4ce2f15f829809fb98cadd7f81484 100644
|
| --- a/tests/standalone/io/file_test.dart
|
| +++ b/tests/standalone/io/file_test.dart
|
| @@ -200,7 +200,7 @@ class FileTest {
|
| // Read a file and check part of it's contents.
|
| String filename = getFilename("bin/file_test.cc");
|
| File file = new File(filename);
|
| - file.open(FileMode.READ).then((RandomAccessFile file) {
|
| + file.open(mode: FileMode.READ).then((RandomAccessFile file) {
|
| List<int> buffer = new List<int>(10);
|
| file.readList(buffer, 0, 5).then((bytes_read) {
|
| Expect.equals(5, bytes_read);
|
| @@ -262,7 +262,7 @@ class FileTest {
|
| // Read a file.
|
| String inFilename = getFilename("tests/vm/data/fixed_length_file");
|
| final File file = new File(inFilename);
|
| - file.open(FileMode.READ).then((openedFile) {
|
| + file.open(mode: FileMode.READ).then((openedFile) {
|
| List<int> buffer1 = new List<int>(42);
|
| openedFile.readList(buffer1, 0, 42).then((bytes_read) {
|
| Expect.equals(42, bytes_read);
|
| @@ -276,12 +276,12 @@ class FileTest {
|
| if (s[0] != '/' && s[0] != '\\' && s[1] != ':') {
|
| Expect.fail("Not a full path");
|
| }
|
| - file2.open(FileMode.WRITE).then((openedFile2) {
|
| + file2.open(mode: FileMode.WRITE).then((openedFile2) {
|
| openedFile2.writeList(buffer1, 0, bytes_read).then((ignore) {
|
| openedFile2.close().then((ignore) {
|
| List<int> buffer2 = new List<int>(bytes_read);
|
| final File file3 = new File(outFilename);
|
| - file3.open(FileMode.READ).then((openedFile3) {
|
| + file3.open(mode: FileMode.READ).then((openedFile3) {
|
| openedFile3.readList(buffer2, 0, 42).then((bytes_read) {
|
| Expect.equals(42, bytes_read);
|
| openedFile3.close().then((ignore) {
|
| @@ -320,17 +320,17 @@ class FileTest {
|
| file.createSync();
|
| Expect.isTrue(new File(filename).existsSync());
|
| List<int> buffer = content.codeUnits;
|
| - RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
|
| + RandomAccessFile openedFile = file.openSync(mode: FileMode.WRITE);
|
| openedFile.writeListSync(buffer, 0, buffer.length);
|
| openedFile.closeSync();
|
| // Reopen the file in write mode to ensure that we overwrite the content.
|
| - openedFile = (new File(filename)).openSync(FileMode.WRITE);
|
| + openedFile = (new File(filename)).openSync(mode: FileMode.WRITE);
|
| openedFile.writeListSync(buffer, 0, buffer.length);
|
| Expect.equals(content.length, openedFile.lengthSync());
|
| openedFile.closeSync();
|
| // Open the file in append mode and ensure that we do not overwrite
|
| // the existing content.
|
| - openedFile = (new File(filename)).openSync(FileMode.APPEND);
|
| + openedFile = (new File(filename)).openSync(mode: FileMode.APPEND);
|
| openedFile.writeListSync(buffer, 0, buffer.length);
|
| Expect.equals(content.length * 2, openedFile.lengthSync());
|
| openedFile.closeSync();
|
| @@ -353,7 +353,7 @@ class FileTest {
|
| appendingOutput.close();
|
| appendingOutput.done.then((_) {
|
| File file3 = new File(filename);
|
| - file3.open(FileMode.READ).then((RandomAccessFile openedFile) {
|
| + file3.open(mode: FileMode.READ).then((RandomAccessFile openedFile) {
|
| openedFile.length().then((int length) {
|
| Expect.equals(content.length * 2, length);
|
| openedFile.close().then((ignore) {
|
| @@ -416,7 +416,7 @@ class FileTest {
|
| Expect.fail("Not a full path");
|
| }
|
| Expect.isTrue(new File(path).existsSync());
|
| - RandomAccessFile openedFile = outFile.openSync(FileMode.WRITE);
|
| + RandomAccessFile openedFile = outFile.openSync(mode: FileMode.WRITE);
|
| openedFile.writeListSync(buffer1, 0, bytes_read);
|
| openedFile.closeSync();
|
| // Now read the contents of the file just written.
|
| @@ -450,7 +450,7 @@ class FileTest {
|
| File file = new File(fileName);
|
| asyncTestStarted();
|
| file.create().then((ignore) {
|
| - file.open(FileMode.READ).then((RandomAccessFile openedFile) {
|
| + file.open(mode: FileMode.READ).then((RandomAccessFile openedFile) {
|
| var readByteFuture = openedFile.readByte();
|
| readByteFuture.then((int byte) {
|
| Expect.equals(-1, byte);
|
| @@ -468,7 +468,7 @@ class FileTest {
|
| final String fileName = "${tempDirectory.path}/testWriteVariousLists";
|
| final File file = new File(fileName);
|
| file.create().then((ignore) {
|
| - file.open(FileMode.WRITE).then((RandomAccessFile openedFile) {
|
| + file.open(mode: FileMode.WRITE).then((RandomAccessFile openedFile) {
|
| // Write bytes from 0 to 7.
|
| openedFile.writeList([0], 0, 1);
|
| openedFile.writeList(const [1], 0, 1);
|
| @@ -629,7 +629,7 @@ class FileTest {
|
| static void testTruncate() {
|
| File file = new File(tempDirectory.path + "/out_truncate");
|
| List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65];
|
| - file.open(FileMode.WRITE).then((RandomAccessFile openedFile) {
|
| + file.open(mode: FileMode.WRITE).then((RandomAccessFile openedFile) {
|
| openedFile.writeList(buffer, 0, 10).then((ignore) {
|
| openedFile.length().then((length) {
|
| Expect.equals(10, length);
|
| @@ -655,7 +655,7 @@ class FileTest {
|
| static void testTruncateSync() {
|
| File file = new File(tempDirectory.path + "/out_truncate_sync");
|
| List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65];
|
| - RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
|
| + RandomAccessFile openedFile = file.openSync(mode: FileMode.WRITE);
|
| openedFile.writeListSync(buffer, 0, 10);
|
| Expect.equals(10, openedFile.lengthSync());
|
| openedFile.truncateSync(5);
|
| @@ -670,7 +670,7 @@ class FileTest {
|
| bool exceptionCaught = false;
|
| bool wrongExceptionCaught = false;
|
| File input = new File(tempDirectory.path + "/out_close_exception");
|
| - RandomAccessFile openedFile = input.openSync(FileMode.WRITE);
|
| + RandomAccessFile openedFile = input.openSync(mode: FileMode.WRITE);
|
| openedFile.closeSync();
|
| try {
|
| openedFile.readByteSync();
|
| @@ -778,7 +778,7 @@ class FileTest {
|
| bool wrongExceptionCaught = false;
|
| File file =
|
| new File(tempDirectory.path + "/out_buffer_out_of_bounds");
|
| - RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
|
| + RandomAccessFile openedFile = file.openSync(mode: FileMode.WRITE);
|
| try {
|
| List<int> buffer = new List<int>(10);
|
| openedFile.readListSync(buffer, 0, 12);
|
| @@ -872,7 +872,7 @@ class FileTest {
|
|
|
| static void testOpenDirectoryAsFile() {
|
| var f = new File('.');
|
| - var future = f.open(FileMode.READ);
|
| + var future = f.open(mode: FileMode.READ);
|
| future.then((r) => Expect.fail('Directory opened as file'))
|
| .catchError((e) {});
|
| }
|
| @@ -947,20 +947,20 @@ class FileTest {
|
| });
|
| var name = getFilename("tests/vm/data/fixed_length_file");
|
| var f = new File(name);
|
| - f.readAsString(Encoding.UTF_8).then((text) {
|
| + f.readAsString(encoding: Encoding.UTF_8).then((text) {
|
| Expect.isTrue(text.endsWith("42 bytes."));
|
| Expect.equals(42, text.length);
|
| var name = getDataFilename("tests/standalone/io/read_as_text.dat");
|
| var f = new File(name);
|
| - f.readAsString(Encoding.UTF_8).then((text) {
|
| + f.readAsString(encoding: Encoding.UTF_8).then((text) {
|
| Expect.equals(6, text.length);
|
| var expected = [955, 120, 46, 32, 120, 10];
|
| Expect.listEquals(expected, text.codeUnits);
|
| - f.readAsString(Encoding.ISO_8859_1).then((text) {
|
| + f.readAsString(encoding: Encoding.ISO_8859_1).then((text) {
|
| Expect.equals(7, text.length);
|
| var expected = [206, 187, 120, 46, 32, 120, 10];
|
| Expect.listEquals(expected, text.codeUnits);
|
| - var readAsStringFuture = f.readAsString(Encoding.ASCII);
|
| + var readAsStringFuture = f.readAsString(encoding: Encoding.ASCII);
|
| readAsStringFuture.then((text) {
|
| Expect.fail("Non-ascii char should cause error");
|
| }).catchError((e) {
|
| @@ -979,7 +979,7 @@ class FileTest {
|
| });
|
| var name = getFilename("tests/vm/data/empty_file");
|
| var f = new File(name);
|
| - f.readAsString(Encoding.UTF_8).then((text) {
|
| + f.readAsString(encoding: Encoding.UTF_8).then((text) {
|
| port.toSendPort().send(text.length);
|
| return true;
|
| });
|
| @@ -995,11 +995,11 @@ class FileTest {
|
| Expect.equals(6, text.length);
|
| var expected = [955, 120, 46, 32, 120, 10];
|
| Expect.listEquals(expected, text.codeUnits);
|
| - text = new File(name).readAsStringSync(Encoding.ASCII);
|
| + text = new File(name).readAsStringSync(encoding: Encoding.ASCII);
|
| // Default replacement character is '?', char code 63.
|
| expected = [63, 63, 120, 46, 32, 120, 10];
|
| Expect.listEquals(expected, text.codeUnits);
|
| - text = new File(name).readAsStringSync(Encoding.ISO_8859_1);
|
| + text = new File(name).readAsStringSync(encoding: Encoding.ISO_8859_1);
|
| expected = [206, 187, 120, 46, 32, 120, 10];
|
| Expect.equals(7, text.length);
|
| Expect.listEquals(expected, text.codeUnits);
|
| @@ -1019,7 +1019,7 @@ class FileTest {
|
| });
|
| var name = getFilename("tests/vm/data/fixed_length_file");
|
| var f = new File(name);
|
| - f.readAsLines(Encoding.UTF_8).then((lines) {
|
| + f.readAsLines(encoding: Encoding.UTF_8).then((lines) {
|
| Expect.equals(1, lines.length);
|
| var line = lines[0];
|
| Expect.isTrue(line.endsWith("42 bytes."));
|
| @@ -1053,10 +1053,10 @@ class FileTest {
|
| var readAsBytesFuture = f.readAsBytes();
|
| readAsBytesFuture.then((bytes) => Expect.fail("no bytes expected"))
|
| .catchError((e) {
|
| - var readAsStringFuture = f.readAsString(Encoding.UTF_8);
|
| + var readAsStringFuture = f.readAsString(encoding: Encoding.UTF_8);
|
| readAsStringFuture.then((text) => Expect.fail("no text expected"))
|
| .catchError((e) {
|
| - var readAsLinesFuture = f.readAsLines(Encoding.UTF_8);
|
| + var readAsLinesFuture = f.readAsLines(encoding: Encoding.UTF_8);
|
| readAsLinesFuture.then((lines) => Expect.fail("no lines expected"))
|
| .catchError((e) {
|
| port.toSendPort().send(1);
|
| @@ -1084,10 +1084,10 @@ class FileTest {
|
| // that the file is not truncated when opened for appending.
|
| static void testAppend() {
|
| var file = new File('${tempDirectory.path}/out_append');
|
| - file.open(FileMode.WRITE).then((openedFile) {
|
| + file.open(mode: FileMode.WRITE).then((openedFile) {
|
| openedFile.writeString("asdf").then((ignore) {
|
| openedFile.close().then((ignore) {
|
| - file.open(FileMode.APPEND).then((openedFile) {
|
| + file.open(mode: FileMode.APPEND).then((openedFile) {
|
| openedFile.length().then((length) {
|
| Expect.equals(4, length);
|
| openedFile.writeString("asdf").then((ignore) {
|
| @@ -1113,11 +1113,11 @@ class FileTest {
|
|
|
| static void testAppendSync() {
|
| var file = new File('${tempDirectory.path}/out_append_sync');
|
| - var openedFile = file.openSync(FileMode.WRITE);
|
| + var openedFile = file.openSync(mode: FileMode.WRITE);
|
| openedFile.writeStringSync("asdf");
|
| Expect.equals(4, openedFile.lengthSync());
|
| openedFile.closeSync();
|
| - openedFile = file.openSync(FileMode.WRITE);
|
| + openedFile = file.openSync(mode: FileMode.WRITE);
|
| openedFile.setPositionSync(4);
|
| openedFile.writeStringSync("asdf");
|
| Expect.equals(8, openedFile.lengthSync());
|
| @@ -1129,12 +1129,12 @@ class FileTest {
|
| static void testWriteStringUtf8() {
|
| var file = new File('${tempDirectory.path}/out_write_string');
|
| var string = new String.fromCharCodes([0x192]);
|
| - file.open(FileMode.WRITE).then((openedFile) {
|
| + file.open(mode: FileMode.WRITE).then((openedFile) {
|
| openedFile.writeString(string).then((_) {
|
| openedFile.length().then((l) {
|
| Expect.equals(2, l);
|
| openedFile.close().then((_) {
|
| - file.open(FileMode.APPEND).then((openedFile) {
|
| + file.open(mode: FileMode.APPEND).then((openedFile) {
|
| openedFile.setPosition(2).then((_) {
|
| openedFile.writeString(string).then((_) {
|
| openedFile.length().then((l) {
|
| @@ -1164,11 +1164,11 @@ class FileTest {
|
| static void testWriteStringUtf8Sync() {
|
| var file = new File('${tempDirectory.path}/out_write_string_sync');
|
| var string = new String.fromCharCodes([0x192]);
|
| - var openedFile = file.openSync(FileMode.WRITE);
|
| + var openedFile = file.openSync(mode: FileMode.WRITE);
|
| openedFile.writeStringSync(string);
|
| Expect.equals(2, openedFile.lengthSync());
|
| openedFile.closeSync();
|
| - openedFile = file.openSync(FileMode.APPEND);
|
| + openedFile = file.openSync(mode: FileMode.APPEND);
|
| openedFile.setPositionSync(2);
|
| openedFile.writeStringSync(string);
|
| Expect.equals(4, openedFile.lengthSync());
|
|
|