@@ -82,6 +82,41 @@ class RipperTest < TestCase
8282 "whitequark/procarg0.txt" ,
8383 ]
8484
85+ omitted_scan = [
86+ "dos_endings.txt" ,
87+ "heredocs_with_fake_newlines.txt" ,
88+ "rescue_modifier.txt" ,
89+ "seattlerb/block_call_dot_op2_brace_block.txt" ,
90+ "seattlerb/block_command_operation_colon.txt" ,
91+ "seattlerb/block_command_operation_dot.txt" ,
92+ "seattlerb/case_in.txt" ,
93+ "seattlerb/heredoc__backslash_dos_format.txt" ,
94+ "seattlerb/heredoc_backslash_nl.txt" ,
95+ "seattlerb/heredoc_nested.txt" ,
96+ "seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt" ,
97+ "seattlerb/heredoc_squiggly_empty.txt" ,
98+ "seattlerb/masgn_command_call.txt" ,
99+ "seattlerb/messy_op_asgn_lineno.txt" ,
100+ "seattlerb/op_asgn_primary_colon_const_command_call.txt" ,
101+ "seattlerb/parse_pattern_076.txt" ,
102+ "tilde_heredocs.txt" ,
103+ "unparser/corpus/literal/assignment.txt" ,
104+ "unparser/corpus/literal/pattern.txt" ,
105+ "unparser/corpus/semantic/dstr.txt" ,
106+ "variables.txt" ,
107+ "whitequark/dedenting_heredoc.txt" ,
108+ "whitequark/masgn_nested.txt" ,
109+ "whitequark/numparam_ruby_bug_19025.txt" ,
110+ "whitequark/op_asgn_cmd.txt" ,
111+ "whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt" ,
112+ "whitequark/parser_slash_slash_n_escaping_in_literals.txt" ,
113+ "whitequark/pattern_matching_nil_pattern.txt" ,
114+ "whitequark/ruby_bug_12402.txt" ,
115+ "whitequark/ruby_bug_18878.txt" ,
116+ "whitequark/send_block_chain_cmd.txt" ,
117+ "whitequark/slash_newline_in_heredocs.txt" ,
118+ ]
119+
85120 Fixture . each_for_current_ruby ( except : incorrect | omitted_sexp_raw ) do |fixture |
86121 define_method ( "#{ fixture . test_name } _sexp_raw" ) { assert_ripper_sexp_raw ( fixture . read ) }
87122 end
@@ -100,6 +135,9 @@ def test_lex_ignored_missing_heredoc_end
100135 end
101136 end
102137
138+ UNSUPPORTED_EVENTS = %i[ backtick comma heredoc_beg heredoc_end ignored_nl kw label_end lbrace lbracket lparen nl op rbrace rbracket rparen semicolon sp symbeg tstring_beg tstring_end words_sep ignored_sp ]
139+ SUPPORTED_EVENTS = Translation ::Ripper ::EVENTS - UNSUPPORTED_EVENTS
140+
103141 module Events
104142 attr_reader :events
105143
@@ -108,9 +146,9 @@ def initialize(...)
108146 @events = [ ]
109147 end
110148
111- Prism :: Translation :: Ripper :: PARSER_EVENTS . each do |event |
149+ SUPPORTED_EVENTS . each do |event |
112150 define_method ( :"on_#{ event } " ) do |*args |
113- @events << [ event , *args ]
151+ @events << [ event , *args . map ( & :to_s ) ]
114152 super ( *args )
115153 end
116154 end
@@ -126,28 +164,25 @@ class PrismEvents < Translation::Ripper
126164
127165 class ObjectEvents < Translation ::Ripper
128166 OBJECT = BasicObject . new
129- Prism :: Translation :: Ripper :: PARSER_EVENTS . each do |event |
167+ SUPPORTED_EVENTS . each do |event |
130168 define_method ( :"on_#{ event } " ) { |*args | OBJECT }
131169 end
132170 end
133171
134- Fixture . each_for_current_ruby ( except : incorrect ) do |fixture |
172+ Fixture . each_for_current_ruby ( except : incorrect | omitted_scan ) do |fixture |
135173 define_method ( "#{ fixture . test_name } _events" ) do
136174 source = fixture . read
137175 # Similar to test/ripper/assert_parse_files.rb in CRuby
138176 object_events = ObjectEvents . new ( source )
139177 assert_nothing_raised { object_events . parse }
140- end
141- end
142178
143- def test_events
144- source = "1 rescue 2"
145- ripper = RipperEvents . new ( source )
146- prism = PrismEvents . new ( source )
147- ripper . parse
148- prism . parse
149- # This makes sure that the content is the same. Ordering is not correct for now.
150- assert_equal ( ripper . events . sort , prism . events . sort )
179+ ripper = RipperEvents . new ( source )
180+ prism = PrismEvents . new ( source )
181+ ripper . parse
182+ prism . parse
183+ # This makes sure that the content is the same. Ordering is not correct for now.
184+ assert_equal ( ripper . events . sort , prism . events . sort )
185+ end
151186 end
152187
153188 def test_lexer
0 commit comments