diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2022-05-01 19:13:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-01 19:13:05 -0700 |
commit | 1d51b1649e75b8d2e8ca81c9aab08c9f119a6ab5 (patch) | |
tree | 34a43636b16c0bc3a2b90cd40aa132d74a8f064a /cli/tests/unit/files_test.ts | |
parent | de33017a8bc3ddc79664df0fae3ded5607b38180 (diff) |
fix(runtime): lossy utf8 readTextFile (#14456)
Diffstat (limited to 'cli/tests/unit/files_test.ts')
-rw-r--r-- | cli/tests/unit/files_test.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/tests/unit/files_test.ts b/cli/tests/unit/files_test.ts index a509672c0..d15f1f538 100644 --- a/cli/tests/unit/files_test.ts +++ b/cli/tests/unit/files_test.ts @@ -791,3 +791,19 @@ Deno.test( assertEquals(res, "hello world!"); }, ); + +Deno.test( + { permissions: { read: true, write: true } }, + async function readTextFileNonUtf8() { + const path = await Deno.makeTempFile(); + const file = await Deno.open(path, { write: true }); + await file.write(new TextEncoder().encode("hello ")); + await file.write(new Uint8Array([0xC0])); + file.close(); + + const res = await Deno.readTextFile(path); + const resSync = Deno.readTextFileSync(path); + assertEquals(res, resSync); + assertEquals(res, "hello \uFFFD"); + }, +); |