11cb0ef41Sopenharmony_cifunction decode(input, output, desc) {
21cb0ef41Sopenharmony_ci  test(function() {
31cb0ef41Sopenharmony_ci    var d = new TextDecoder("iso-2022-jp"),
41cb0ef41Sopenharmony_ci        buffer = new ArrayBuffer(input.length),
51cb0ef41Sopenharmony_ci        view = new Int8Array(buffer)
61cb0ef41Sopenharmony_ci    for(var i = 0, l = input.length; i < l; i++) {
71cb0ef41Sopenharmony_ci      view[i] = input[i]
81cb0ef41Sopenharmony_ci    }
91cb0ef41Sopenharmony_ci    assert_equals(d.decode(view), output)
101cb0ef41Sopenharmony_ci  }, "iso-2022-jp decoder: " + desc)
111cb0ef41Sopenharmony_ci}
121cb0ef41Sopenharmony_cidecode([0x1b, 0x24], "�$", "Error ESC")
131cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x50], "�$P", "Error ESC, character")
141cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x42, 0x50], "P", "ASCII ESC, character")
151cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x42, 0x1b, 0x28, 0x42, 0x50], "�P", "Double ASCII ESC, character")
161cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x28, 0x42, 0x50], "PP", "character, ASCII ESC, character")
171cb0ef41Sopenharmony_cidecode([0x5C, 0x5D, 0x7E], "\\]~", "characters")
181cb0ef41Sopenharmony_cidecode([0x0D, 0x0E, 0x0F, 0x10], "\x0D��\x10", "SO / SI")
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x4A, 0x5C, 0x5D, 0x7E], "¥]‾", "Roman ESC, characters")
211cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x4A, 0x0D, 0x0E, 0x0F, 0x10], "\x0D��\x10", "Roman ESC, SO / SI")
221cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x4A, 0x1b, 0x1b, 0x28, 0x49, 0x50], "�ミ", "Roman ESC, error ESC, Katakana ESC")
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x49, 0x50], "ミ", "Katakana ESC, character")
251cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x49, 0x1b, 0x24, 0x40, 0x50, 0x50], "�佩", "Katakana ESC, multibyte ESC, character")
261cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x49, 0x1b, 0x50], "�ミ", "Katakana ESC, error ESC, character")
271cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x49, 0x1b, 0x24, 0x50], "�、ミ", "Katakana ESC, error ESC #2, character")
281cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x49, 0x50, 0x1b, 0x28, 0x49, 0x50], "ミミ", "Katakana ESC, character, Katakana ESC, character")
291cb0ef41Sopenharmony_cidecode([0x1b, 0x28, 0x49, 0x0D, 0x0E, 0x0F, 0x10], "����", "Katakana ESC, SO / SI")
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x50, 0x50], "佩", "Multibyte ESC, character")
321cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x42, 0x50, 0x50], "佩", "Multibyte ESC #2, character")
331cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x42, 0x1b, 0x50, 0x50], "�佩", "Multibyte ESC, error ESC, character")
341cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x40], "�", "Double multibyte ESC")
351cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x40, 0x50, 0x50], "�佩", "Double multibyte ESC, character")
361cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x42, 0x50, 0x50], "�佩", "Double multibyte ESC #2, character")
371cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x50, 0x50], "�ば�", "Multibyte ESC, error ESC #2, character")
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x50, 0x1b, 0x24, 0x40, 0x50, 0x50], "�佩", "Multibyte ESC, single byte, multibyte ESC, character")
401cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x20, 0x50], "��", "Multibyte ESC, lead error byte")
411cb0ef41Sopenharmony_cidecode([0x1b, 0x24, 0x40, 0x50, 0x20], "�", "Multibyte ESC, trail error byte")
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_cidecode([0x50, 0x1b], "P�", "character, error ESC")
441cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x24], "P�$", "character, error ESC #2")
451cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x50], "P�P", "character, error ESC #3")
461cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x28, 0x42], "P", "character, ASCII ESC")
471cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x28, 0x4A], "P", "character, Roman ESC")
481cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x28, 0x49], "P", "character, Katakana ESC")
491cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x24, 0x40], "P", "character, Multibyte ESC")
501cb0ef41Sopenharmony_cidecode([0x50, 0x1b, 0x24, 0x42], "P", "character, Multibyte ESC #2")
51