Skip to content

Fix FrameInfo#block_identifier #1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 3 additions & 1 deletion lib/debug/frame_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def frame_type

def block_identifier
return unless frame_type == :block
_, level, block_loc = location.label.match(BLOCK_LABL_REGEXP).to_a
re_match = location.label.match(BLOCK_LABL_REGEXP)
_, level, block_loc = re_match ? re_match.to_a : [nil, nil, location.label]

[level || "", block_loc]
end

Expand Down
58 changes: 58 additions & 0 deletions test/console/frame_block_identifier_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

require_relative '../support/console_test_case'

module DEBUGGER__

class FrameBlockIdentifierTest < ConsoleTestCase
def program
<<~RUBY
1|
2| class Whatever
3| def some_method
4| will_exit = false
5| loop do
6| return if will_exit
7| will_exit = true
8|
9| begin
10| raise "foo"
11| rescue => e
12| puts "the end"
13| end
14| end
15| end
16| end
17|
18| Whatever.new.some_method
RUBY
end

def test_frame_block_identifier
debug_code(program) do
type 'b 12'
type 'c'
assert_line_num 12
assert_line_text([
/\[7, 16\] in .*/,
/ 7\| will_exit = true/,
/ 8\| /,
/ 9\| begin/,
/ 10\| raise "foo"/,
/ 11\| rescue => e/,
/=> 12\| puts "the end"/,
/ 13\| end/,
/ 14\| end/,
/ 15\| end/,
/ 16\| end/,
/=>\#0\tWhatever\#some_method at .*/,
/ \#1\tblock in Kernel\#loop at <internal:kernel>:168/,
/ \# and 2 frames \(use `bt' command for all frames\)/,
//,
/Stop by \#0 BP \- Line .*/
])
type 'c'
end
end
end
end