| Index: tests/standalone/io/file_test.dart
|
| diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
|
| index 4fd426a75a74d90346bc7b051c07c3ca94ae5c6a..e0f2d17d308dec6a2d5b77748f4861d7005de103 100644
|
| --- a/tests/standalone/io/file_test.dart
|
| +++ b/tests/standalone/io/file_test.dart
|
| @@ -1218,6 +1218,59 @@ class FileTest {
|
| Expect.isFalse(file.existsSync());
|
| }
|
|
|
| + static void testWriteStringUtf8() {
|
| + var file = new File('${tempDirectory.path}/out_write_string');
|
| + var string = new String.fromCharCodes([0x192]);
|
| + file.open(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) {
|
| + openedFile.setPosition(2).then((_) {
|
| + openedFile.writeString(string).then((_) {
|
| + openedFile.length().then((l) {
|
| + Expect.equals(4, l);
|
| + openedFile.close().then((_) {
|
| + file.readAsText().then((readBack) {
|
| + Expect.stringEquals(readBack, '$string$string');
|
| + file.delete().then((_) {
|
| + file.exists().then((e) {
|
| + Expect.isFalse(e);
|
| + asyncTestDone("testWriteStringUtf8");
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + asyncTestStarted();
|
| + }
|
| +
|
| + 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);
|
| + openedFile.writeStringSync(string);
|
| + Expect.equals(2, openedFile.lengthSync());
|
| + openedFile.closeSync();
|
| + openedFile = file.openSync(FileMode.APPEND);
|
| + openedFile.setPositionSync(2);
|
| + openedFile.writeStringSync(string);
|
| + Expect.equals(4, openedFile.lengthSync());
|
| + openedFile.closeSync();
|
| + var readBack = file.readAsTextSync();
|
| + Expect.stringEquals(readBack, '$string$string');
|
| + file.deleteSync();
|
| + Expect.isFalse(file.existsSync());
|
| + }
|
| +
|
| // Helper method to be able to run the test from the runtime
|
| // directory, or the top directory.
|
| static String getFilename(String path) =>
|
| @@ -1273,6 +1326,8 @@ class FileTest {
|
| testWriteVariousLists();
|
| testDirectory();
|
| testDirectorySync();
|
| + testWriteStringUtf8();
|
| + testWriteStringUtf8Sync();
|
| });
|
| }
|
| }
|
|
|