File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 22require 'test/unit'
33
44class 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\0 bar" ,
@@ -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
You can’t perform that action at this time.
0 commit comments