Skip to content

Commit

Permalink
Remove stepping capabilities in irb command
Browse files Browse the repository at this point in the history
There are several reasons for this:
- `next` command inside `irb` never really worked, because the `next`
keyword in Ruby would get executed instead (see
nixme/pry-nav#20)
- Commands were very limited, they couldn't handle any arguments like
the regular `next`, `step` and `cont` commands.
- It causes issues with the Rails console (see
[deivid-rodriguez/pry-byebug#30).
  • Loading branch information
David Rodríguez de Dios committed Aug 14, 2014
1 parent 6ff31d5 commit 8e226d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 59 deletions.
46 changes: 2 additions & 44 deletions lib/byebug/commands/repl.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
module IRB
module ExtendCommand
class Continue
def self.execute(conf)
throw :IRB_EXIT, :cont
end
end
class Next
def self.execute(conf)
throw :IRB_EXIT, :next
end
end
class Step
def self.execute(conf)
throw :IRB_EXIT, :step
end
end
end

require 'irb'
ExtendCommandBundle.def_extend_command 'cont', :Continue
ExtendCommandBundle.def_extend_command 'next', :Next
ExtendCommandBundle.def_extend_command 'step', :Step
end
require 'irb'

module Byebug
class IrbCommand < Command
Expand All @@ -36,21 +13,6 @@ def execute
end

cont = IRB.start(__FILE__)
case cont
when :cont
@state.proceed
when :step
force = Setting[:forcestep]
@state.context.step_into 1, force
@state.proceed
when :next
force = Setting[:forcestep]
@state.context.step_over 1, @state.frame_pos, force
@state.proceed
else
print @state.location
@state.previous_line = nil
end
end

class << self
Expand All @@ -59,11 +21,7 @@ def names
end

def description
%{irb\tstarts an Interactive Ruby (IRB) session.
IRB is extended with methods "cont", "n" and "step" which run the
corresponding byebug commands. In contrast to the real byebug commands
these commands don't allow arguments.}
%{irb\tstarts an Interactive Ruby (IRB) session.}
end
end
end
Expand Down
18 changes: 3 additions & 15 deletions test/irb_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,10 @@ def setup
interface.stubs(:kind_of?).with(LocalInterface).returns(true)
end

def test_irb_supports_next_command
IRB::Irb.any_instance.stubs(:eval_input).throws(:IRB_EXIT, :next)
def test_irb_command_starts_an_irb_session
IrbCommand.any_instance.expects(:execute)
enter 'irb'
debug_proc(@example) { assert_equal 7, state.line }
end

def test_irb_supports_step_command
IRB::Irb.any_instance.stubs(:eval_input).throws(:IRB_EXIT, :step)
enter 'irb'
debug_proc(@example) { assert_equal 7, state.line }
end

def test_irb_supports_cont_command
IRB::Irb.any_instance.stubs(:eval_input).throws(:IRB_EXIT, :cont)
enter 'break 8', 'irb'
debug_proc(@example) { assert_equal 8, state.line }
debug_proc(@example)
end

def test_autoirb_calls_irb_automatically_after_every_stop
Expand Down

0 comments on commit 8e226d0

Please sign in to comment.