@@ -424,8 +424,8 @@ describe('Common implementation mistakes', () => {
424424 } )
425425 } )
426426
427- // Bun fails at this
428- describe ( 'BOM splitting' , ( ) => {
427+ describe ( 'BOM splitting / repeats' , ( ) => {
428+ // Bun fails at this
429429 test ( 'utf-8' , ( t ) => {
430430 const d = new TextDecoder ( )
431431 const check = ( a , opt , str ) => t . assert . strictEqual ( d . decode ( Uint8Array . from ( a ) , opt ) , str )
@@ -455,6 +455,42 @@ describe('Common implementation mistakes', () => {
455455 check ( [ 0xef ] , { stream : true } , '' )
456456 check ( [ 0xbb , 0xbf , 42 , 43 ] , { } , '*+' ) // close
457457 } )
458+
459+ // Bun fails at this
460+ test ( 'utf-16le' , ( t ) => {
461+ const d = new TextDecoder ( 'utf-16le' )
462+ const check = ( a , opt , str ) => t . assert . strictEqual ( d . decode ( Uint8Array . from ( a ) , opt ) , str )
463+
464+ check ( [ 0xff , 0xfe ] , { stream : true } , '' )
465+ check ( [ 0x03 , 0x00 ] , { } , '\x03' ) // close
466+
467+ check ( [ 0xff ] , { stream : true } , '' )
468+ check ( [ 0xfe , 0x03 , 0x00 ] , { } , '\x03' ) // close
469+
470+ check ( [ 0xff , 0xfe ] , { stream : true } , '' )
471+ check ( [ 0xff , 0xfe , 0x03 , 0x00 ] , { } , '\uFEFF\x03' ) // close
472+
473+ check ( [ 0xff ] , { stream : true } , '' )
474+ check ( [ 0xfe , 0xff , 0xfe , 0x03 , 0x00 ] , { } , '\uFEFF\x03' ) // close
475+ } )
476+
477+ // Bun fails at this
478+ test ( 'utf-16be' , ( t ) => {
479+ const d = new TextDecoder ( 'utf-16be' )
480+ const check = ( a , opt , str ) => t . assert . strictEqual ( d . decode ( Uint8Array . from ( a ) , opt ) , str )
481+
482+ check ( [ 0xfe , 0xff ] , { stream : true } , '' )
483+ check ( [ 0x00 , 0x03 ] , { } , '\x03' ) // close
484+
485+ check ( [ 0xfe ] , { stream : true } , '' )
486+ check ( [ 0xff , 0x00 , 0x03 ] , { } , '\x03' ) // close
487+
488+ check ( [ 0xfe , 0xff ] , { stream : true } , '' )
489+ check ( [ 0xfe , 0xff , 0x00 , 0x03 ] , { } , '\uFEFF\x03' ) // close
490+
491+ check ( [ 0xfe ] , { stream : true } , '' )
492+ check ( [ 0xff , 0xfe , 0xff , 0x00 , 0x03 ] , { } , '\uFEFF\x03' ) // close
493+ } )
458494 } )
459495 } )
460496
0 commit comments