@@ -3,6 +3,13 @@ import { test, describe } from 'node:test'
33import { readFileSync } from 'node:fs'
44import { join } from 'node:path'
55
6+ const SharedArrayBuffer = globalThis . SharedArrayBuffer ?? ArrayBuffer
7+ const toShared = ( u8 ) => {
8+ const res = new Uint8Array ( new SharedArrayBuffer ( u8 . length ) )
9+ res . set ( u8 )
10+ return res
11+ }
12+
613describe ( 'multi-byte encodings are supersets of ascii' , ( ) => {
714 // Except iso-2022-jp
815 for ( const encoding of [ 'big5' , 'euc-kr' , 'euc-jp' , 'shift_jis' , 'gbk' , 'gb18030' ] ) {
@@ -19,7 +26,7 @@ describe('multi-byte encodings are supersets of ascii', () => {
1926
2027 t . assert . strictEqual ( str . length , 1 , i )
2128 t . assert . strictEqual ( str . codePointAt ( 0 ) , i , i )
22-
29+ t . assert . strictEqual ( decoder ( toShared ( Uint8Array . of ( i ) ) ) , str )
2330 t . assert . deepStrictEqual ( encoder ( str ) , Uint8Array . of ( i ) )
2431 }
2532 } )
@@ -222,6 +229,7 @@ describe('roundtrip, tables', () => {
222229 }
223230
224231 t . assert . doesNotThrow ( ( ) => t . assert . strictEqual ( dec ( enc ( str ) ) , str ) , description )
232+ t . assert . doesNotThrow ( ( ) => t . assert . strictEqual ( dec ( toShared ( enc ( str ) ) ) , str ) , description )
225233 }
226234 } )
227235 }
0 commit comments