diff options
Diffstat (limited to 'test/ruby/test_rubyoptions.rb')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 6db6126e28..2e5f76d692 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -768,6 +768,34 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-e", "puts ARGV", "*.txt"], "", ougai) end end + + def assert_e_script_encoding(str, args = []) + cmds = [ + EnvUtil::LANG_ENVS.inject({}) {|h, k| h[k] = ENV[k]; h}, + *args, + '-e', "s = '#{str}'", + '-e', 'puts s.encoding.name', + '-e', 'puts s.dump', + ] + assert_in_out_err(cmds, "", [str.encoding.name, str.dump], [], + "#{str.encoding}:#{str.dump} #{args.inspect}") + end + + # tested codepages: 437 850 852 855 932 65001 + # Since the codepage is shared all processes per conhost.exe, do + # not chcp, or parallel test may break. + def test_locale_codepage + locale = Encoding.find("locale") + list = %W"\u{c7} \u{452} \u{3066 3059 3068}" + list.each do |s| + assert_e_script_encoding(s, %w[-U]) + end + list.each do |s| + s = s.encode(locale) rescue next + assert_e_script_encoding(s) + assert_e_script_encoding(s, %W[-E#{locale.name}]) + end + end when /cygwin/ def test_command_line_non_ascii assert_separately([{"LC_ALL"=>"ja_JP.SJIS"}, "-", "\u{3042}".encode("SJIS")], <<-"end;") |