Sha256: 76a52183e7d351d8f330e702b4e4a44ba05c6fbe69bd676208c40cbac9d518b1
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
# See that setting ISEQS__ and SCRIPT_ISEQS__ saves # RubyVM::Instruction_sequenses require 'test/unit' class TestIseqAccess < Test::Unit::TestCase def setup old_verbosity = $VERBOSE $VERBOSE = nil Kernel.const_set(:ISEQS__, {}) Kernel.const_set(:SCRIPT_ISEQS__, {}) $VERBOSE = old_verbosity end def teardown old_verbosity = $VERBOSE $VERBOSE = nil Kernel.const_set(:ISEQS__, nil) Kernel.const_set(:SCRIPT_ISEQS__, nil) $VERBOSE = old_verbosity end def test_basic sizes=[] [ISEQS__, SCRIPT_ISEQS__].each do |iseq_hash| sizes << iseq_hash.size end # defining five should trigger five instruction sequence additions # to ISEQS__ and SCRIPT_ISEQS__ # eval 'def five; 5 end' assert_equal sizes[0], sizes[1] [SCRIPT_ISEQS__, ISEQS__].each do |iseq_hash| assert_equal true, iseq_hash.size > sizes.pop assert_equal Hash, iseq_hash.class a = iseq_hash.first assert_equal Array, a.class assert_equal RubyVM::InstructionSequence, iseq_hash.values[0][0].class end end # Check RubyVM::InstructionSequence#arity def test_arity eval 'def five; 5 end' eval 'def add(a,b); a+b end' eval 'def splat(*a); 5 end' [['five', 0,], ['add', 2], ['splat', -1]].each do |meth, expect| assert_equal(expect, ISEQS__[meth][0].arity) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rb-threadframe-0.39 | test/ruby/test_iseq.rb |
rb-threadframe-0.37 | test/ruby/test_iseq.rb |