Skip to content

Commit

Permalink
[Bug #20984] Fix test with locale encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Dec 26, 2024
1 parent f459d8d commit d78ff6a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/ruby/test_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -361,7 +363,7 @@ def test_inspect_encoding
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
Expand Down Expand Up @@ -409,8 +411,7 @@ def test_assoc
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
Expand Down Expand Up @@ -524,7 +525,7 @@ def test_huge_value
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
Expand Down

0 comments on commit d78ff6a

Please sign in to comment.