diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-12-26 23:48:05 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-12-27 00:21:41 +0900 |
commit | d78ff6a767ca813ac5fa178dd7611f20a993c191 (patch) | |
tree | 1ee159908caace0fe2f42788cbb241272c778777 | |
parent | f459d8dfb7720a61d3f49af71fcd6bcf28bbca3f (diff) |
[Bug #20984] Fix test with locale encoding
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12474
-rw-r--r-- | test/ruby/test_env.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 02c3ea1d43..c9ec920ea9 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -2,7 +2,9 @@ require 'test/unit' class TestEnv < Test::Unit::TestCase - IGNORE_CASE = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM + windows = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM + IGNORE_CASE = windows + ENCODING = windows ? Encoding::UTF_8 : Encoding.find("locale") PATH_ENV = "PATH" INVALID_ENVVARS = [ "foo\0bar", @@ -361,7 +363,7 @@ class TestEnv < Test::Unit::TestCase ENV.clear key = "VAR\u{e5 e1 e2 e4 e3 101 3042}" ENV[key] = "foo" - assert_equal(%{{"VAR\u{e5 e1 e2 e4 e3 101 3042}" => "foo"}}, ENV.inspect) + assert_equal(%{{#{(key.encode(ENCODING) rescue key.b).inspect} => "foo"}}, ENV.inspect) end def test_to_a @@ -409,8 +411,7 @@ class TestEnv < Test::Unit::TestCase assert_equal("foo", v) end assert_invalid_env {|var| ENV.assoc(var)} - encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? Encoding::UTF_8 : Encoding.find("locale") - assert_equal(encoding, v.encoding) + assert_equal(ENCODING, v.encoding) end def test_has_value2 @@ -524,7 +525,7 @@ class TestEnv < Test::Unit::TestCase assert_equal(huge_value, ENV["foo"]) end - if /mswin|mingw/ =~ RUBY_PLATFORM + if windows def windows_version @windows_version ||= %x[ver][/Version (\d+)/, 1].to_i end |