6 class TestRipper_ParserEvents < Test::Unit::TestCase
10 def test_event_coverage
11 dispatched = Ripper::PARSER_EVENTS.map {|event,*| event }
12 dispatched.each do |e|
13 assert_equal true, respond_to?("test_#{e}", true),
14 "event not tested: #{e.inspect}"
20 DummyParser.new(str).parse.to_s
26 assert_equal '[void()]', parse('')
27 assert_equal true, $thru_program
31 assert_equal '[void()]', parse('')
35 assert_equal '[ref(nil)]', parse('nil')
36 assert_equal '[ref(nil),ref(nil)]', parse('nil;nil')
37 assert_equal '[ref(nil),ref(nil),ref(nil)]', parse('nil;nil;nil')
41 assert_equal '[void()]', parse('')
42 assert_equal '[void()]', parse('; ;')
46 assert_equal '[ref(a)]', parse('a')
47 assert_equal '[ref(nil)]', parse('nil')
48 assert_equal '[ref(true)]', parse('true')
52 assert_equal '[BEGIN([void()])]', parse('BEGIN{}')
53 assert_equal '[BEGIN([ref(nil)])]', parse('BEGIN{nil}')
57 assert_equal '[END([void()])]', parse('END{}')
58 assert_equal '[END([ref(nil)])]', parse('END{nil}')
62 assert_equal '[alias(symbol_literal(a),symbol_literal(b))]', parse('alias a b')
66 assert_equal '[valias($a,$g)]', parse('alias $a $g')
70 assert_equal '[aliaserr(valias($a,$1))]', parse('alias $a $1')
74 assert_equal '[fcall(m,[])]', parse('m()')
75 assert_equal '[fcall(m,[1])]', parse('m(1)')
76 assert_equal '[fcall(m,[1,2])]', parse('m(1,2)')
77 assert_equal '[fcall(m,[*ref(r)])]', parse('m(*r)')
78 assert_equal '[fcall(m,[1,*ref(r)])]', parse('m(1,*r)')
79 assert_equal '[fcall(m,[1,2,*ref(r)])]', parse('m(1,2,*r)')
80 assert_equal '[fcall(m,[&ref(r)])]', parse('m(&r)')
81 assert_equal '[fcall(m,[1,&ref(r)])]', parse('m(1,&r)')
82 assert_equal '[fcall(m,[1,2,&ref(r)])]', parse('m(1,2,&r)')
83 assert_equal '[fcall(m,[*ref(a),&ref(b)])]', parse('m(*a,&b)')
84 assert_equal '[fcall(m,[1,*ref(a),&ref(b)])]', parse('m(1,*a,&b)')
85 assert_equal '[fcall(m,[1,2,*ref(a),&ref(b)])]', parse('m(1,2,*a,&b)')
93 assert_equal '[aref(ref(v),[1])]', parse('v[1]')
94 assert_equal '[aref(ref(v),[1,2])]', parse('v[1,2]')
98 assert_equal '[fcall(m,[assocs(assoc(1,2))])]', parse('m(1=>2)')
99 assert_equal '[fcall(m,[assocs(assoc(1,2),assoc(3,4))])]', parse('m(1=>2,3=>4)')
100 assert_equal '[fcall(m,[3,assocs(assoc(1,2))])]', parse('m(3,1=>2)')
104 assert_equal '[assign(aref_field(ref(a),[1]),2)]', parse('a[1]=2')
108 def test_arg_ambiguous
109 assert_equal true, $thru__arg_ambiguous
113 def test_array # array literal
114 assert_equal '[array([1,2,3])]', parse('[1,2,3]')
117 def test_assign # generic assignment
118 assert_equal '[assign(var_field(v),1)]', parse('v=1')
122 def test_assign_error
123 assert_equal true, $thru__assign_error
127 assert_equal true, $thru__begin
131 assert_equal true, $thru__binary
135 assert_equal true, $thru__block_var
139 assert_equal true, $thru__bodystmt
143 assert_equal true, $thru__brace_block
147 assert_equal true, $thru__break
151 assert_equal true, $thru__call
155 assert_equal true, $thru__case
159 assert_equal true, $thru__class
162 def test_class_name_error
163 assert_equal true, $thru__class_name_error
167 assert_equal true, $thru__command
170 def test_command_call
171 assert_equal true, $thru__command_call
175 assert_equal true, $thru__const_ref
178 def test_constpath_field
179 assert_equal true, $thru__constpath_field
182 def test_constpath_ref
183 assert_equal true, $thru__constpath_ref
187 assert_equal true, $thru__def
191 assert_equal true, $thru__defined
195 assert_equal true, $thru__defs
199 assert_equal true, $thru__do_block
203 assert_equal true, $thru__dot2
207 assert_equal true, $thru__dot3
211 assert_equal true, $thru__dyna_symbol
215 assert_equal true, $thru__else
219 assert_equal true, $thru__elsif
223 assert_equal true, $thru__ensure
227 assert_equal true, $thru__fcall
231 assert_equal true, $thru__field
235 assert_equal true, $thru__for
239 assert_equal true, $thru__hash
243 assert_equal true, $thru__if
247 assert_equal true, $thru__if_mod
251 assert_equal true, $thru__ifop
255 assert_equal true, $thru__iter_block
259 assert_equal true, $thru__massign
262 def test_method_add_arg
263 assert_equal true, $thru__method_add_arg
267 assert_equal true, $thru__mlhs_add
270 def test_mlhs_add_star
271 assert_equal true, $thru__mlhs_add_star
275 assert_equal true, $thru__mlhs_new
279 assert_equal true, $thru__mlhs_paren
283 assert_equal true, $thru__module
287 assert_equal true, $thru__mrhs_add
290 def test_mrhs_add_star
291 assert_equal true, $thru__mrhs_add_star
295 assert_equal true, $thru__mrhs_new
298 def test_mrhs_new_from_arglist
299 assert_equal true, $thru__mrhs_new_from_arglist
303 assert_equal true, $thru__next
307 assert_equal true, $thru__opassign
311 assert_equal true, $thru__param_error
315 assert_equal true, $thru__params
319 assert_equal true, $thru__paren
323 assert_equal true, $thru__parse_error
327 assert_equal true, $thru__qwords_add
331 assert_equal true, $thru__qwords_new
335 assert_equal true, $thru__redo
338 def test_regexp_literal
339 assert_equal true, $thru__regexp_literal
343 assert_equal true, $thru__rescue
347 assert_equal true, $thru__rescue_mod
351 assert_equal true, $thru__restparam
355 assert_equal true, $thru__retry
359 assert_equal true, $thru__return
363 assert_equal true, $thru__return0
367 assert_equal true, $thru__sclass
371 assert_equal true, $thru__space
375 assert_equal true, $thru__string_add
378 def test_string_concat
379 assert_equal true, $thru__string_concat
382 def test_string_content
383 assert_equal true, $thru__string_content
387 assert_equal true, $thru__string_dvar
390 def test_string_embexpr
391 assert_equal true, $thru__string_embexpr
394 def test_string_literal
395 assert_equal true, $thru__string_literal
399 assert_equal true, $thru__super
403 assert_equal true, $thru__symbol
406 def test_symbol_literal
407 assert_equal true, $thru__symbol_literal
410 def test_topconst_field
411 assert_equal true, $thru__topconst_field
414 def test_topconst_ref
415 assert_equal true, $thru__topconst_ref
419 assert_equal true, $thru__unary
423 assert_equal true, $thru__undef
427 assert_equal true, $thru__unless
431 assert_equal true, $thru__unless_mod
435 assert_equal true, $thru__until_mod
439 assert_equal true, $thru__var_field
443 assert_equal true, $thru__when
447 assert_equal true, $thru__while
451 assert_equal true, $thru__while_mod
455 assert_equal true, $thru__word_add
459 assert_equal true, $thru__word_new
463 assert_equal true, $thru__words_add
467 assert_equal true, $thru__words_new
471 assert_equal true, $thru__xstring_add
474 def test_xstring_literal
475 assert_equal true, $thru__xstring_literal
479 assert_equal true, $thru__xstring_new
483 assert_equal true, $thru__yield
487 assert_equal true, $thru__yield0
491 assert_equal true, $thru__zsuper