diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-11-18 11:39:59 -0800 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-11-19 07:12:50 +0900 |
commit | 4a5c42db88d30532bd4fbcdff89615ebf961d2a2 (patch) | |
tree | 8ed563a01104757d8521c300fb41ad1d52fdc5bb /test/ruby/test_iseq.rb | |
parent | fee0073726655827b7b7dcd0481b2119fdbf89f5 (diff) | |
download | ruby-4a5c42db88d30532bd4fbcdff89615ebf961d2a2.tar.gz |
Make RubyVM::InstructionSequence.compile_file use same encoding as load
This switches the internal function from rb_parser_compile_file_path
to rb_parser_load_file, which is the same internal method that
Kernel#load uses.
Fixes [Bug #17308]
Diffstat (limited to 'test/ruby/test_iseq.rb')
-rw-r--r-- | test/ruby/test_iseq.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 51e3fd0391..3ec06b4042 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -98,6 +98,22 @@ class TestISeq < Test::Unit::TestCase assert_include(RubyVM::InstructionSequence.of(obj.method(name)).disasm, name) end + def test_compile_file_encoding + Tempfile.create(%w"test_iseq .rb") do |f| + f.puts "{ '\u00de' => 'Th', '\u00df' => 'ss', '\u00e0' => 'a' }" + f.close + + previous_external = Encoding.default_external + Encoding.default_external = Encoding::US_ASCII + begin + load f.path + RubyVM::InstructionSequence.compile_file(f.path) + ensure + Encoding.default_external = previous_external + end + end + end + LINE_BEFORE_METHOD = __LINE__ def method_test_line_trace |