diff options
| author | Andy Waite <andyw8@users.noreply.github.com> | 2023-08-29 16:42:43 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-09-06 18:37:41 +0000 |
| commit | fdf7aad902ccc9e2f32e4b6b3e21fb68a8788d16 (patch) | |
| tree | cad230e27e923e4ccf9ca3a401e5e01237fda7c2 | |
| parent | 12102d101af258d7a3e9695b736a189cd3658df1 (diff) | |
[ruby/yarp] Fix `Location#end_column`
https://github.com/ruby/yarp/commit/00e4711026
| -rw-r--r-- | lib/yarp.rb | 2 | ||||
| -rw-r--r-- | test/yarp/location_test.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/yarp.rb b/lib/yarp.rb index 0dab1515fc..769b149bca 100644 --- a/lib/yarp.rb +++ b/lib/yarp.rb @@ -95,7 +95,7 @@ module YARP # The column number in bytes where this location ends from the start of the # line. def end_column - source.column(end_offset - 1) + source.column(end_offset) end def deconstruct_keys(keys) diff --git a/test/yarp/location_test.rb b/test/yarp/location_test.rb index 4509fc0cf5..d86afb0b3b 100644 --- a/test/yarp/location_test.rb +++ b/test/yarp/location_test.rb @@ -817,6 +817,14 @@ module YARP node = result.value.statements.body.last 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_equal expected.begin, node.location.start_offset assert_equal expected.end, node.location.end_offset |
