diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 15:43:05 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 15:43:05 +0000 |
commit | 3e8c0c577cde58cc00d975d533b9416a80ba12ec (patch) | |
tree | 0601ebfa914ea4441ab7c6115c075c52a050ae9f /test/ruby/test_rubyoptions.rb | |
parent | 8949479e1a77ad62c054cd2db9b129f65c560f90 (diff) | |
download | ruby-3e8c0c577cde58cc00d975d533b9416a80ba12ec.tar.gz |
The encoding of __FILE__ and __dir__ should be same
* ruby.c (process_options): convert the real path of the script to locale
encoding if its encoding is not locale (maybe UTF-8) on Windows/OS X.
this change makes the encoding of __dir__ to the same encoding of __FILE__
when the script name is passed from commandline.
* test/ruby/test_options.rb (test___dir__encoding): test for this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rubyoptions.rb')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index beb6a24e93..27969690d8 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -935,4 +935,20 @@ class TestRubyOptions < Test::Unit::TestCase end end end + + def test___dir__encoding + with_tmpchdir do + testdir = "\u30c6\u30b9\u30c8" + Dir.mkdir(testdir) + Dir.chdir(testdir) do + open("test.rb", "w") do |f| + f.puts <<-END + p __FILE__.encoding == __dir__.encoding + END + end + r, = EnvUtil.invoke_ruby("test.rb", "", true) + assert_equal "true", r.chomp, "the encoding of __FILE__ and __dir__ should be same" + end + end + end end |