@@ -345,13 +345,15 @@ def test_regexp_completor_handles_encoding_errors_gracefully
345345 end
346346
347347 def test_utf16_method_name_does_not_crash
348- if RUBY_ENGINE == 'truffleruby'
349- omit "TruffleRuby does not support UTF-16 methods."
350- end
351348 # Reproduces issue #52: https://github.com/ruby/irb/issues/52
352- method_name = "test_utf16_method" . encode ( Encoding :: UTF_16 )
349+ # Tests UTF-16, UTF-16LE, and UTF-16BE encodings
353350 test_obj = Object . new
354- test_obj . define_singleton_method ( method_name ) { }
351+
352+ if RUBY_ENGINE != 'truffleruby'
353+ test_obj . define_singleton_method ( "test_utf16_method" . encode ( Encoding ::UTF_16 ) ) { }
354+ end
355+ test_obj . define_singleton_method ( "test_utf16le_method" . encode ( Encoding ::UTF_16LE ) ) { }
356+ test_obj . define_singleton_method ( "test_utf16be_method" . encode ( Encoding ::UTF_16BE ) ) { }
355357 test_bind = test_obj . instance_eval { binding }
356358
357359 completor = IRB ::RegexpCompletor . new
@@ -360,7 +362,11 @@ def test_utf16_method_name_does_not_crash
360362 result = completor . completion_candidates ( '' , 'test' , '' , bind : test_bind )
361363 end
362364
363- assert_include result , "test_utf16_method"
365+ if RUBY_ENGINE != 'truffleruby'
366+ assert_include result , "test_utf16_method"
367+ end
368+ assert_include result , "test_utf16le_method"
369+ assert_include result , "test_utf16be_method"
364370 end
365371 end
366372end
0 commit comments