summaryrefslogtreecommitdiff
path: root/test/prism/ruby_api_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/prism/ruby_api_test.rb')
-rw-r--r--test/prism/ruby_api_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/prism/ruby_api_test.rb b/test/prism/ruby_api_test.rb
index 49296117bf..6418887147 100644
--- a/test/prism/ruby_api_test.rb
+++ b/test/prism/ruby_api_test.rb
@@ -198,6 +198,17 @@ module Prism
assert_equal 7, location.end_code_units_column(Encoding::UTF_32LE)
end
+ def test_location_chop
+ location = Prism.parse("foo").value.location
+
+ assert_equal "fo", location.chop.slice
+ assert_equal "", location.chop.chop.chop.slice
+
+ # Check that we don't go negative.
+ 10.times { location = location.chop }
+ assert_equal "", location.slice
+ end
+
def test_heredoc?
refute parse_expression("\"foo\"").heredoc?
refute parse_expression("\"foo \#{1}\"").heredoc?