1require 'test/unit' 2require '-test-/debug' 3 4class TestDebug < Test::Unit::TestCase 5 6 def binds_check binds 7 count = Hash.new(0) 8 assert_instance_of(Array, binds) 9 binds.each{|(_self, bind, klass, iseq, loc)| 10 if _self == self 11 count[:self] += 1 12 end 13 14 if bind 15 assert_instance_of(Binding, bind) 16 count[:bind] += 1 17 end 18 19 if klass 20 assert(klass.instance_of?(Module) || klass.instance_of?(Class)) 21 count[:class] += 1 22 end 23 24 if iseq 25 count[:iseq] += 1 26 assert_instance_of(RubyVM::InstructionSequence, iseq) 27 28 # check same location 29 assert_equal(loc.path, iseq.path) 30 assert_equal(loc.absolute_path, iseq.absolute_path) 31 assert_equal(loc.label, iseq.label) 32 assert_operator(loc.lineno, :>=, iseq.first_lineno) 33 end 34 35 assert_instance_of(Thread::Backtrace::Location, loc) 36 37 } 38 assert_operator(0, :<, count[:self]) 39 assert_operator(0, :<, count[:bind]) 40 assert_operator(0, :<, count[:iseq]) 41 assert_operator(0, :<, count[:class]) 42 end 43 44 def test_inspector_open 45 binds = Bug::Debug.inspector 46 binds_check binds 47 end 48 49 def inspector_in_eval 50 eval("Bug::Debug.inspector") 51 end 52 53 def test_inspector_open_in_eval 54 bug7635 = '[ruby-core:51640]' 55 binds = inspector_in_eval 56 binds_check binds 57 end 58end 59