Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,10 @@ def format_prompt(format, ltype, indent, line_no) # :nodoc:
when "N"
@context.irb_name
when "m"
main_str = @context.safe_method_call_on_main(:to_s) rescue "!#{$!.class}"
main_str = "#{@context.safe_method_call_on_main(:to_s)}" rescue "!#{$!.class}"
truncate_prompt_main(main_str)
when "M"
main_str = @context.safe_method_call_on_main(:inspect) rescue "!#{$!.class}"
main_str = "#{@context.safe_method_call_on_main(:inspect)}" rescue "!#{$!.class}"
truncate_prompt_main(main_str)
when "l"
ltype
Expand Down
25 changes: 25 additions & 0 deletions test/irb/test_debugger_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,31 @@ def test_debug
assert_match(/=> 2\| puts "hello"/, output)
end

def test_debug_class_to_s_return_nil
write_ruby <<~'ruby'
class ToSReturnsNil
def to_s
nil
end

def do_something
binding.irb
end
end

ToSReturnsNil.new.do_something
ruby

output = run_ruby_file do
type "debug"
type "next"
type "continue"
end

assert_match(/irb\(\):001> debug/, output)
assert_match(/irb:rdbg\(\):002> next/, output)
end

def test_debug_command_only_runs_once
write_ruby <<~'ruby'
binding.irb
Expand Down