summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-28 01:32:50 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-01 20:28:44 +0900
commit60d0421ca861944459f52292d65dbf0ece26e38a (patch)
treeee9cc26547bad6b3d51ada81562b2fbb767a6220 /test
parent8e9d696ed01d782ad49f2e7b351802ec244ee1bf (diff)
Fix the encoding of loaded feature names [Bug #18191]
The feature names loaded from the default load paths should also be in the file system encoding.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4915
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_require.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 401b274ef6..30df2ed849 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -531,6 +531,28 @@ class TestRequire < Test::Unit::TestCase
$".replace(features)
end
+ def test_default_loaded_features_encoding
+ Dir.mktmpdir {|tmp|
+ Dir.mkdir("#{tmp}/1")
+ Dir.mkdir("#{tmp}/2")
+ File.write("#{tmp}/1/bug18191-1.rb", "")
+ File.write("#{tmp}/2/bug18191-2.rb", "")
+ assert_separately(%W[-Eutf-8 -I#{tmp}/1 -], "#{<<~"begin;"}\n#{<<~'end;'}")
+ tmp = #{tmp.dump}"/2"
+ begin;
+ $:.unshift(tmp)
+ require "bug18191-1"
+ require "bug18191-2"
+ encs = [Encoding::US_ASCII, Encoding.find("filesystem")]
+ message = -> {
+ require "pp"
+ {filesystem: encs[1], **$".group_by(&:encoding)}.pretty_inspect
+ }
+ assert($".all? {|n| encs.include?(n.encoding)}, message)
+ end;
+ }
+ end
+
def test_require_changed_current_dir
bug7158 = '[ruby-core:47970]'
Dir.mktmpdir {|tmp|