mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
[ruby/irb] Use correct binding in debug mode
(https://github.com/ruby/irb/pull/1007) In debug command, IRB's context was using wrong binding. Some code colorization, command detection failed because binding.local_variable returned wrong value. https://github.com/ruby/irb/commit/68f718de21
This commit is contained in:
parent
5edc321988
commit
a8a921aef3
@ -56,7 +56,7 @@ module IRB
|
||||
def readline _
|
||||
setup_interrupt do
|
||||
tc = DEBUGGER__::SESSION.instance_variable_get(:@tc)
|
||||
cmd = @irb.debug_readline(tc.current_frame.binding || TOPLEVEL_BINDING)
|
||||
cmd = @irb.debug_readline(tc.current_frame.eval_binding || TOPLEVEL_BINDING)
|
||||
|
||||
case cmd
|
||||
when nil # when user types C-d
|
||||
|
||||
@ -365,6 +365,23 @@ module TestIRB
|
||||
assert_include(output, "InputMethod: RelineInputMethod")
|
||||
end
|
||||
|
||||
def test_irb_command_can_check_local_variables
|
||||
write_ruby <<~'ruby'
|
||||
binding.irb
|
||||
ruby
|
||||
|
||||
output = run_ruby_file do
|
||||
type "debug"
|
||||
type 'foobar = IRB'
|
||||
type "show_source foobar.start"
|
||||
type "show_source = 'Foo'"
|
||||
type "show_source + 'Bar'"
|
||||
type "continue"
|
||||
end
|
||||
assert_include(output, "def start(ap_path = nil)")
|
||||
assert_include(output, '"FooBar"')
|
||||
end
|
||||
|
||||
def test_help_command_is_delegated_to_the_debugger
|
||||
write_ruby <<~'ruby'
|
||||
binding.irb
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user