@@ -339,6 +339,19 @@ def decorated(self, *args, **kwargs):
339339 return outer_decorator
340340
341341
342+ def with_both_text_decoder (f ):
343+ assert callable (f )
344+
345+ @wraps (f )
346+ def decorated (self , textdecoder , * args , ** kwargs ):
347+ self .set_setting ('TEXTDECODER' , textdecoder )
348+ f (self , * args , ** kwargs )
349+
350+ parameterize (decorated , {'' : (0 ,), 'textdecoder' : (2 ,)})
351+
352+ return decorated
353+
354+
342355no_minimal_runtime = make_no_decorator_for_setting ('MINIMAL_RUNTIME' )
343356no_safe_heap = make_no_decorator_for_setting ('SAFE_HEAP' )
344357
@@ -5655,40 +5668,43 @@ def test_utime(self):
56555668 def test_futimens (self ):
56565669 self .do_runf ('utime/test_futimens.c' , 'success' )
56575670
5671+ @with_both_text_decoder
56585672 def test_utf (self ):
56595673 self .do_core_test ('test_utf.c' )
56605674
5675+ @with_both_text_decoder
56615676 def test_utf32 (self ):
56625677 self .do_runf ('utf32.cpp' , 'OK (long).\n ' )
56635678
5679+ @with_both_text_decoder
56645680 @no_sanitize ('requires libc to be built with -fshort-char' )
56655681 def test_utf32_short_wchar (self ):
56665682 if '-flto' in self .emcc_args or '-flto=thin' in self .emcc_args :
56675683 self .skipTest ('-fshort-wchar is not compatible with LTO (libraries would need rebuilting)' )
56685684 self .do_runf ('utf32.cpp' , 'OK (short).\n ' , emcc_args = ['-fshort-wchar' ])
56695685
5686+ @with_both_text_decoder
56705687 @crossplatform
56715688 def test_utf16 (self ):
56725689 self .do_runf ('core/test_utf16.cpp' , 'OK.' )
56735690
5691+ @with_both_text_decoder
56745692 def test_utf8 (self ):
56755693 self .do_runf ('core/test_utf8.c' , 'OK.' )
56765694
5695+ @with_both_text_decoder
56775696 @also_with_wasm_bigint
5678- def test_utf8_textdecoder (self ):
5697+ def test_utf8_bench (self ):
56795698 self .emcc_args += ['--embed-file' , test_file ('utf8_corpus.txt' ) + '@/utf8_corpus.txt' ]
56805699 self .do_runf ('benchmark/benchmark_utf8.c' , 'OK.' )
56815700
56825701 # Test that invalid character in UTF8 does not cause decoding to crash.
5702+ @with_both_text_decoder
56835703 @also_with_minimal_runtime
5684- @parameterized ({
5685- '' : ([],),
5686- 'textdecoder' : (['-sTEXTDECODER' ],),
5687- })
5688- def test_utf8_invalid (self , args ):
5689- self .do_runf ('test_utf8_invalid.c' , 'OK.' , emcc_args = args )
5704+ def test_utf8_invalid (self ):
5705+ self .do_runf ('test_utf8_invalid.c' , 'OK.' )
56905706
5691- def test_utf16_textdecoder (self ):
5707+ def test_utf16_bench (self ):
56925708 self .emcc_args += ['--embed-file' , test_file ('utf16_corpus.txt' ) + '@/utf16_corpus.txt' ]
56935709 self .do_runf ('benchmark/benchmark_utf16.cpp' , 'OK.' )
56945710
0 commit comments