diff options
| author | Stan Lo <stan001212@gmail.com> | 2023-11-23 07:29:08 +0000 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-11-23 07:29:12 +0000 |
| commit | e8b905896482f2952ccbb4d5bf0a1910edd07bf9 (patch) | |
| tree | c1c3c38ce4cdf09f89d8e17cabaeb74c3987539f /test | |
| parent | e2078ccd5a54e54e16bec8db96c45d467307e6c3 (diff) | |
[ruby/irb] Hint debugger command in irb:rdbg session
(https://github.com/ruby/irb/pull/768)
When user enters irb:rdbg session, they don't get the same hint that the
`debug` gem provides, like
```
(rdbg) n # next command
```
This means that users may accidentally execute commands when they want to
retrieve the value of a variable.
So this commit adds a Reline output modifier to add a simiar hint:
```
irb:rdbg(main):002> n # debug command
```
It is not exactly the same as `debug`'s because in this case the importance
is to help users distinguish between value evaluation and debugger command
execution.
https://github.com/ruby/irb/commit/fdf24de851
Diffstat (limited to 'test')
| -rw-r--r-- | test/irb/yamatanooroti/test_rendering.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/irb/yamatanooroti/test_rendering.rb b/test/irb/yamatanooroti/test_rendering.rb index 96051ee433..5d8719ac3f 100644 --- a/test/irb/yamatanooroti/test_rendering.rb +++ b/test/irb/yamatanooroti/test_rendering.rb @@ -379,6 +379,48 @@ class IRB::RenderingTest < Yamatanooroti::TestCase assert_match(/foobar/, screen) end + def test_debug_integration_hints_debugger_commands + write_irbrc <<~'LINES' + IRB.conf[:USE_COLORIZE] = false + LINES + script = Tempfile.create(["debug", ".rb"]) + script.write <<~RUBY + puts 'start IRB' + binding.irb + RUBY + script.close + start_terminal(40, 80, %W{ruby -I#{@pwd}/lib #{script.to_path}}, startup_message: 'start IRB') + write("debug\n") + write("n") + close + + screen = result.join("\n").sub(/\n*\z/, "\n") + assert_include(screen, "irb:rdbg(main):002> n # debug command") + ensure + File.unlink(script) if script + end + + def test_debug_integration_doesnt_hint_non_debugger_commands + write_irbrc <<~'LINES' + IRB.conf[:USE_COLORIZE] = false + LINES + script = Tempfile.create(["debug", ".rb"]) + script.write <<~RUBY + puts 'start IRB' + binding.irb + RUBY + script.close + start_terminal(40, 80, %W{ruby -I#{@pwd}/lib #{script.to_path}}, startup_message: 'start IRB') + write("debug\n") + write("foo") + close + + screen = result.join("\n").sub(/\n*\z/, "\n") + assert_include(screen, "irb:rdbg(main):002> foo\n") + ensure + File.unlink(script) if script + end + private def write_irbrc(content) |
