diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2018-12-07 10:23:29 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-12-06 18:45:10 -0500 |
commit | 568ac0c9026b6f4012e2511a026bb5eb31a06020 (patch) | |
tree | 87a6de900f1366b1e2e38a096f9f3b7cb15c7f7e /js/text_encoding_test.ts | |
parent | 6cc89b9e272440d93b6354f098031c3a22803686 (diff) |
Add ASCII support to TextDecoder
Diffstat (limited to 'js/text_encoding_test.ts')
-rw-r--r-- | js/text_encoding_test.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/js/text_encoding_test.ts b/js/text_encoding_test.ts index 402044e36..efb841fc6 100644 --- a/js/text_encoding_test.ts +++ b/js/text_encoding_test.ts @@ -48,6 +48,23 @@ test(function textDecoder2() { assertEqual(decoder.decode(fixture), "𝓽𝓮𝔁𝓽"); }); +test(function textDecoderASCII() { + const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]); + const decoder = new TextDecoder("ascii"); + assertEqual(decoder.decode(fixture), "‰•Ÿ¿"); +}); + +test(function textDecoderErrorEncoding() { + let didThrow = false; + try { + const decoder = new TextDecoder("foo"); + } catch (e) { + didThrow = true; + assertEqual(e.message, "The encoding label provided ('foo') is invalid."); + } + assert(didThrow); +}); + test(function textEncoder() { const fixture = "������"; const encoder = new TextEncoder(); |