diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-10 03:17:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-10 03:17:30 +0000 |
commit | 8f55d83d4b382ba5f37ca2b7d6241d0deb59f9cc (patch) | |
tree | 262f07e7067fc7fde41bc5e26cf548e38713d89e /test/ruby | |
parent | 422c63bd0ec3c977b90c2d5f1f28f31c50786c52 (diff) | |
download | ruby-8f55d83d4b382ba5f37ca2b7d6241d0deb59f9cc.tar.gz |
compile.c: register cdhash
* compile.c (iseq_build_from_ary_body): register cdhash to the
iseq constant body instead of compile time mark array, not to
get GCed. [ruby-core:70708] [Feature #8543]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_iseq.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 3938fb3d48..72b9c4ae3a 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -51,6 +51,26 @@ class TestISeq < Test::Unit::TestCase assert_raise_with_message(TypeError, /:foobar/) {RubyVM::InstructionSequence.load(ary)} end if defined?(RubyVM::InstructionSequence.load) + def test_loaded_cdhash_mark + iseq = RubyVM::InstructionSequence.compile(<<-'end;', __FILE__, __FILE__, __LINE__+1) + def bug(kw) + case kw + when "false" then false + when "true" then true + when "nil" then nil + else raise("unhandled argument: #{kw.inspect}") + end + end + end; + assert_separately([], <<-"end;") + iseq = #{iseq.to_a.inspect} + RubyVM::InstructionSequence.load(iseq).eval + assert_equal(false, bug("false")) + GC.start + assert_equal(false, bug("false")) + end; + end if defined?(RubyVM::InstructionSequence.load) + def test_disasm_encoding src = "\u{3042} = 1; \u{3042}; \u{3043}" asm = RubyVM::InstructionSequence.compile(src).disasm |