[ruby/yarp] Fix Location#end_column

https://github.com/ruby/yarp/commit/00e4711026
This commit is contained in:
Andy Waite 2023-08-29 16:42:43 -04:00 committed by git
parent 12102d101a
commit fdf7aad902
2 changed files with 9 additions and 1 deletions

View File

@ -95,7 +95,7 @@ module YARP
# The column number in bytes where this location ends from the start of the # The column number in bytes where this location ends from the start of the
# line. # line.
def end_column def end_column
source.column(end_offset - 1) source.column(end_offset)
end end
def deconstruct_keys(keys) def deconstruct_keys(keys)

View File

@ -817,6 +817,14 @@ module YARP
node = result.value.statements.body.last node = result.value.statements.body.last
node = yield node if block_given? node = yield node if block_given?
if expected.begin == 0
assert_equal 0, node.location.start_column
end
if expected.end == source.length
assert_equal source.split("\n").last.length, node.location.end_column
end
assert_kind_of kind, node assert_kind_of kind, node
assert_equal expected.begin, node.location.start_offset assert_equal expected.begin, node.location.start_offset
assert_equal expected.end, node.location.end_offset assert_equal expected.end, node.location.end_offset