10000 [Bug #20984] Fix test with locale encoding · ruby/ruby@d78ff6a · GitHub
[go: up one dir, main page]

Skip to content

Commit d78ff6a

Browse files
committed
[Bug #20984] Fix test with locale encoding
1 parent f459d8d commit d78ff6a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/ruby/test_env.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
require 'test/unit'
33

44
class TestEnv < Test::Unit::TestCase
5-
IGNORE_CASE = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM
5+
windows = /bccwin|mswin|mingw/ =~ RUBY_PLATFORM
6+
IGNORE_CASE = windows
7+
ENCODING = windows ? Encoding::UTF_8 : Encoding.find("locale")
68
PATH_ENV = "PATH"
79
INVALID_ENVVARS = [
810
"foo\0bar",
@@ -361,7 +363,7 @@ def test_inspect_encoding
361363
ENV.clear
362364
key = "VAR\u{e5 e1 e2 e4 e3 101 3042}"
363365
ENV[key] = "foo"
364-
assert_equal(%{{"VAR\u{e5 e1 e2 e4 e3 101 3042}" => "foo"}}, ENV.inspect)
366+
assert_equal(%{{#{(key.encode(ENCODING) rescue key.b).inspect} => "foo"}}, ENV.inspect)
365367
end
366368

367369
def test_to_a
@@ -409,8 +411,7 @@ def test_assoc
409411
assert_equal("foo", v)
410412
end
411413
assert_invalid_env {|var| ENV.assoc(var)}
412-
encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? Encoding::UTF_8 : Encoding.find("locale")
413-
assert_equal(encoding, v.encoding)
414+
assert_equal(ENCODING, v.encoding)
414415
end
415416

416417
def test_has_value2
@@ -524,7 +525,7 @@ def test_huge_value
524525
assert_equal(huge_value, ENV["foo"])
525526
end
526527

527-
if /mswin|mingw/ =~ RUBY_PLATFORM
528+
if windows
528529
def windows_version
529530
@windows_version ||= %x[ver][/Version (\d+)/, 1].to_i
530531
end

0 commit comments

Comments
 (0)
0