summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEarlopain <14981592+Earlopain@users.noreply.github.com>2026-02-03 12:10:01 +0100
committergit <svn-admin@ruby-lang.org>2026-02-03 12:33:30 +0000
commit4bf1cb087bc8ff065b6226037329d7464fa3e96c (patch)
tree0b04083563c702b588ddd20faa5ebd2e1bffd477 /test
parentcf22fe7f0857f0c980d9966047579b65c7798126 (diff)
[ruby/prism] Better guard against syntax invalid code in ripper lex translator
Closes https://github.com/ruby/prism/pull/3899 Also better compatibility by only dropping the last token if it is actually EOF https://github.com/ruby/prism/commit/128ab52be9
Diffstat (limited to 'test')
-rw-r--r--test/prism/ruby/ripper_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/prism/ruby/ripper_test.rb b/test/prism/ruby/ripper_test.rb
index 52a5ad7ef4..758505ac2a 100644
--- a/test/prism/ruby/ripper_test.rb
+++ b/test/prism/ruby/ripper_test.rb
@@ -140,6 +140,17 @@ module Prism
assert_raise(SyntaxError) { Translation::Ripper::Lexer.new("1 +").lex(raise_errors: true) }
end
+
+ # On syntax invalid code the output doesn't always match up
+ # In these cases we just want to make sure that it doesn't raise.
+ def test_lex_invalid_syntax
+ assert_nothing_raised do
+ Translation::Ripper.lex('scan/\p{alpha}/')
+ end
+
+ assert_equal(Ripper.lex('if;)'), Translation::Ripper.lex('if;)'))
+ end
+
def test_tokenize
source = "foo;1;BAZ"
assert_equal(Ripper.tokenize(source), Translation::Ripper.tokenize(source))