summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEarlopain <14981592+Earlopain@users.noreply.github.com>2026-01-08 13:47:35 +0100
committergit <svn-admin@ruby-lang.org>2026-01-08 18:35:26 +0000
commit16863f2ec1c8cefd852965e58acfcfd61b0194b9 (patch)
treedd0e27e2ee83a81c6b0f5779c8415dc803e95370 /test
parentfc66de3e6b5e28c017c3cffac77a66d680d679a4 (diff)
[ruby/prism] Decouple ripper translator from ripper library
Ripper exposes Ripper::Lexer:State in its output, which is a bit of a problem. To make this work, I basically copy-pasted the implementation. I'm unsure if that is acceptable and added a test to make sure that these values never go out of sync. I don't imagine them changing often, prism maps them 1:1 for its own usage. This also fixed the shim by accident. `Ripper.lex` went to `Translation::Ripper.lex` when it should have been the original. Removing the need for the original resolves that issue. https://github.com/ruby/prism/commit/2c0bea076d
Diffstat (limited to 'test')
-rw-r--r--test/prism/ruby/ripper_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/prism/ruby/ripper_test.rb b/test/prism/ruby/ripper_test.rb
index defa95b6a8..9d64c5c70c 100644
--- a/test/prism/ruby/ripper_test.rb
+++ b/test/prism/ruby/ripper_test.rb
@@ -63,6 +63,18 @@ module Prism
define_method(fixture.test_name) { assert_ripper(fixture.read) }
end
+ # Check that the hardcoded values don't change without us noticing.
+ def test_internals
+ actual = LexCompat::State::ALL
+ expected = Ripper.constants.select { |name| name.start_with?("EXPR_") }
+ expected -= %i[EXPR_VALUE EXPR_BEG_ANY EXPR_ARG_ANY EXPR_END_ANY]
+
+ assert_equal(expected.size, actual.size)
+ expected.each do |const_name|
+ assert_equal(const_name.to_s.delete_prefix("EXPR_").to_sym, actual[Ripper.const_get(const_name)])
+ end
+ end
+
private
def assert_ripper(source)