Skip to content

Commit

Permalink
Enable "step <n>" while replay
Browse files Browse the repository at this point in the history
  • Loading branch information
ono-max committed Oct 29, 2022
1 parent 5a30073 commit 046159a
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,9 @@ def wait_next_action_

case step_type
when :in
iter = iter || 1
if @recorder&.replaying?
@recorder.step_forward
@recorder.step_forward iter
raise SuspendReplay
else
step_tp iter do
Expand Down Expand Up @@ -1191,8 +1192,11 @@ def step_back
@index += 1
end

def step_forward
@index -= 1
def step_forward iter
@index -= iter
if @index < 0
@index = 0
end
end

def step_reset
Expand Down
80 changes: 80 additions & 0 deletions test/console/record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,84 @@ def test_1656237686
end
end
end

class StepIntoWithNumWhileReplayTest < ConsoleTestCase
def program
<<~RUBY
1| def a
2| return b()
3| end
4|
5| def b
6| return 1
7| end
8|
9| a()
10| a()
11| a()
12| a()
13| a()
14| a()
RUBY
end

def test_1663647719
debug_code(program) do
type 'record on'
type 'b 11'
type 'c'
assert_line_num 11
type 'step back'
assert_line_num 11
type 'step back'
assert_line_num 6
type 'step back'
assert_line_num 2
type 'step back'
assert_line_num 10
type 'step 2'
assert_line_num 6
type 'step 2'
assert_line_num 11
type 'q!'
end
end
end

class StepIntoWhenNumberIsLargetThanLogIndex < ConsoleTestCase
def program
<<~RUBY
1| def a
2| return b()
3| end
4|
5| def b
6| return 1
7| end
8|
9| a()
10| a()
11| a()
12| a()
13| a()
14| a()
RUBY
end

def test_1663647719
debug_code(program) do
type 'record on'
type 'b 11'
type 'c'
assert_line_num 11
type 'step back'
assert_line_num 11
type 'step back'
assert_line_num 6
type 'step 100'
assert_line_num 11
type 'q!'
end
end
end
end

0 comments on commit 046159a

Please sign in to comment.