From 568ac0c9026b6f4012e2511a026bb5eb31a06020 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Fri, 7 Dec 2018 10:23:29 +1100 Subject: Add ASCII support to TextDecoder --- js/text_encoding_test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/text_encoding_test.ts') 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(); -- cgit v1.2.3