melbourne 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/HISTORY +3 -0
  2. data/LICENSE +27 -0
  3. data/README.rdoc +38 -0
  4. data/Rakefile +38 -0
  5. data/VERSION.yml +4 -0
  6. data/ext/melbourne/bstring-license.txt +29 -0
  7. data/ext/melbourne/bstrlib.c +2918 -0
  8. data/ext/melbourne/bstrlib.h +302 -0
  9. data/ext/melbourne/extconf.rb +76 -0
  10. data/ext/melbourne/grammar.cpp +11885 -0
  11. data/ext/melbourne/grammar.hpp +14 -0
  12. data/ext/melbourne/grammar.y +6013 -0
  13. data/ext/melbourne/internal.hpp +137 -0
  14. data/ext/melbourne/lex.c.tab +136 -0
  15. data/ext/melbourne/local_state.hpp +41 -0
  16. data/ext/melbourne/melbourne.cpp +37 -0
  17. data/ext/melbourne/node.hpp +262 -0
  18. data/ext/melbourne/node_types.cpp +245 -0
  19. data/ext/melbourne/node_types.hpp +135 -0
  20. data/ext/melbourne/node_types.rb +190 -0
  21. data/ext/melbourne/quark.cpp +52 -0
  22. data/ext/melbourne/quark.hpp +14 -0
  23. data/ext/melbourne/symbols.cpp +219 -0
  24. data/ext/melbourne/symbols.hpp +116 -0
  25. data/ext/melbourne/var_table.cpp +113 -0
  26. data/ext/melbourne/var_table.hpp +33 -0
  27. data/ext/melbourne/visitor.cpp +1052 -0
  28. data/ext/melbourne/visitor.hpp +20 -0
  29. data/lib/melbourne/ast/constants.rb +128 -0
  30. data/lib/melbourne/ast/control_flow.rb +382 -0
  31. data/lib/melbourne/ast/data.rb +19 -0
  32. data/lib/melbourne/ast/definitions.rb +561 -0
  33. data/lib/melbourne/ast/exceptions.rb +182 -0
  34. data/lib/melbourne/ast/file.rb +15 -0
  35. data/lib/melbourne/ast/grapher.rb +75 -0
  36. data/lib/melbourne/ast/literals.rb +268 -0
  37. data/lib/melbourne/ast/node.rb +21 -0
  38. data/lib/melbourne/ast/operators.rb +117 -0
  39. data/lib/melbourne/ast/self.rb +17 -0
  40. data/lib/melbourne/ast/sends.rb +451 -0
  41. data/lib/melbourne/ast/values.rb +74 -0
  42. data/lib/melbourne/ast/variables.rb +251 -0
  43. data/lib/melbourne/ast.rb +22 -0
  44. data/lib/melbourne/parser.rb +38 -0
  45. data/lib/melbourne/processor.rb +460 -0
  46. data/lib/melbourne.rb +46 -0
  47. data/spec/helpers/ast/node.rb +15 -0
  48. data/spec/helpers/ast/reduced_graph.rb +64 -0
  49. data/spec/lib/parser/alias_spec.rb +97 -0
  50. data/spec/lib/parser/and_spec.rb +63 -0
  51. data/spec/lib/parser/array_spec.rb +157 -0
  52. data/spec/lib/parser/attrasgn_spec.rb +401 -0
  53. data/spec/lib/parser/back_ref_spec.rb +20 -0
  54. data/spec/lib/parser/call_spec.rb +958 -0
  55. data/spec/lib/parser/case_spec.rb +577 -0
  56. data/spec/lib/parser/cdecl_spec.rb +108 -0
  57. data/spec/lib/parser/class_spec.rb +221 -0
  58. data/spec/lib/parser/colon2_spec.rb +13 -0
  59. data/spec/lib/parser/colon3_spec.rb +12 -0
  60. data/spec/lib/parser/const_spec.rb +12 -0
  61. data/spec/lib/parser/cvar_spec.rb +55 -0
  62. data/spec/lib/parser/cvasgn_spec.rb +71 -0
  63. data/spec/lib/parser/cvdecl_spec.rb +31 -0
  64. data/spec/lib/parser/defined_spec.rb +353 -0
  65. data/spec/lib/parser/defn_spec.rb +1409 -0
  66. data/spec/lib/parser/defs_spec.rb +247 -0
  67. data/spec/lib/parser/dot2_spec.rb +29 -0
  68. data/spec/lib/parser/dot3_spec.rb +29 -0
  69. data/spec/lib/parser/dregx_spec.rb +127 -0
  70. data/spec/lib/parser/dstr_spec.rb +453 -0
  71. data/spec/lib/parser/dsym_spec.rb +31 -0
  72. data/spec/lib/parser/dxstr_spec.rb +31 -0
  73. data/spec/lib/parser/ensure_spec.rb +279 -0
  74. data/spec/lib/parser/false_spec.rb +12 -0
  75. data/spec/lib/parser/flip2_spec.rb +138 -0
  76. data/spec/lib/parser/flip3_spec.rb +100 -0
  77. data/spec/lib/parser/for_spec.rb +279 -0
  78. data/spec/lib/parser/gasgn_spec.rb +34 -0
  79. data/spec/lib/parser/gvar_spec.rb +33 -0
  80. data/spec/lib/parser/hash_spec.rb +77 -0
  81. data/spec/lib/parser/iasgn_spec.rb +54 -0
  82. data/spec/lib/parser/if_spec.rb +439 -0
  83. data/spec/lib/parser/iter_spec.rb +2582 -0
  84. data/spec/lib/parser/lasgn_spec.rb +1066 -0
  85. data/spec/lib/parser/lit_spec.rb +75 -0
  86. data/spec/lib/parser/masgn_spec.rb +1970 -0
  87. data/spec/lib/parser/match2_spec.rb +47 -0
  88. data/spec/lib/parser/match3_spec.rb +54 -0
  89. data/spec/lib/parser/match_spec.rb +19 -0
  90. data/spec/lib/parser/module_spec.rb +102 -0
  91. data/spec/lib/parser/nil_spec.rb +13 -0
  92. data/spec/lib/parser/not_spec.rb +39 -0
  93. data/spec/lib/parser/nth_ref_spec.rb +12 -0
  94. data/spec/lib/parser/op_asgn_spec.rb +619 -0
  95. data/spec/lib/parser/or_spec.rb +155 -0
  96. data/spec/lib/parser/postexe_spec.rb +31 -0
  97. data/spec/lib/parser/regex_spec.rb +52 -0
  98. data/spec/lib/parser/rescue_spec.rb +1028 -0
  99. data/spec/lib/parser/return_spec.rb +151 -0
  100. data/spec/lib/parser/sclass_spec.rb +172 -0
  101. data/spec/lib/parser/str_spec.rb +162 -0
  102. data/spec/lib/parser/super_spec.rb +276 -0
  103. data/spec/lib/parser/true_spec.rb +12 -0
  104. data/spec/lib/parser/undef_spec.rb +222 -0
  105. data/spec/lib/parser/until_spec.rb +286 -0
  106. data/spec/lib/parser/valias_spec.rb +12 -0
  107. data/spec/lib/parser/while_spec.rb +458 -0
  108. data/spec/lib/parser/xstr_spec.rb +12 -0
  109. data/spec/lib/parser/yield_spec.rb +202 -0
  110. data/spec/lib/parser/zsuper_spec.rb +101 -0
  111. data/spec/matchers/parse_as.rb +27 -0
  112. data/spec/spec_helper.rb +10 -0
  113. metadata +168 -0
@@ -0,0 +1,2582 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Melbourne::Parser do
4
+
5
+ it 'should correctly parse "m { }"' do
6
+ ruby = 'm { }'
7
+ ast = {:send=>
8
+ {:@block=>
9
+ {:iter=>
10
+ {:@body=>{},
11
+ :@line=>1,
12
+ :@arguments=>
13
+ {:iterarguments=>
14
+ {:@block=>nil,
15
+ :@arity=>-1,
16
+ :@prelude=>nil,
17
+ :@optional=>0,
18
+ :@splat=>nil,
19
+ :@line=>1,
20
+ :@splat_index=>-2,
21
+ :@required_args=>0}}}},
22
+ :@name=>:m,
23
+ :@line=>1,
24
+ :@privately=>true,
25
+ :@receiver=>{:self=>{:@line=>1}},
26
+ :@check_for_local=>false}}
27
+
28
+ ruby.should parse_as(ast)
29
+ end
30
+
31
+ it 'should correctly parse "m do end"' do
32
+ ruby = 'm do end'
33
+ ast = {:send=>
34
+ {:@block=>
35
+ {:iter=>
36
+ {:@body=>{},
37
+ :@line=>1,
38
+ :@arguments=>
39
+ {:iterarguments=>
40
+ {:@block=>nil,
41
+ :@arity=>-1,
42
+ :@prelude=>nil,
43
+ :@optional=>0,
44
+ :@splat=>nil,
45
+ :@line=>1,
46
+ :@splat_index=>-2,
47
+ :@required_args=>0}}}},
48
+ :@name=>:m,
49
+ :@line=>1,
50
+ :@privately=>true,
51
+ :@receiver=>{:self=>{:@line=>1}},
52
+ :@check_for_local=>false}}
53
+
54
+ ruby.should parse_as(ast)
55
+ end
56
+
57
+ it 'should correctly parse "m { x }"' do
58
+ ruby = 'm { x }'
59
+ ast = {:send=>
60
+ {:@block=>
61
+ {:iter=>
62
+ {:@body=>
63
+ {:send=>
64
+ {:@block=>nil,
65
+ :@name=>:x,
66
+ :@line=>1,
67
+ :@privately=>true,
68
+ :@receiver=>{:self=>{:@line=>1}},
69
+ :@check_for_local=>false}},
70
+ :@line=>1,
71
+ :@arguments=>
72
+ {:iterarguments=>
73
+ {:@block=>nil,
74
+ :@arity=>-1,
75
+ :@prelude=>nil,
76
+ :@optional=>0,
77
+ :@splat=>nil,
78
+ :@line=>1,
79
+ :@splat_index=>-2,
80
+ :@required_args=>0}}}},
81
+ :@name=>:m,
82
+ :@line=>1,
83
+ :@privately=>true,
84
+ :@receiver=>{:self=>{:@line=>1}},
85
+ :@check_for_local=>false}}
86
+
87
+ ruby.should parse_as(ast)
88
+ end
89
+
90
+ it 'should correctly parse "m { || x }"' do
91
+ ruby = 'm { || x }'
92
+ ast = {:send=>
93
+ {:@block=>
94
+ {:iter=>
95
+ {:@body=>
96
+ {:send=>
97
+ {:@block=>nil,
98
+ :@name=>:x,
99
+ :@line=>1,
100
+ :@privately=>true,
101
+ :@receiver=>{:self=>{:@line=>1}},
102
+ :@check_for_local=>false}},
103
+ :@line=>1,
104
+ :@arguments=>
105
+ {:iterarguments=>
106
+ {:@block=>nil,
107
+ :@arity=>0,
108
+ :@prelude=>nil,
109
+ :@optional=>0,
110
+ :@splat=>nil,
111
+ :@line=>1,
112
+ :@splat_index=>-1,
113
+ :@required_args=>0}}}},
114
+ :@name=>:m,
115
+ :@line=>1,
116
+ :@privately=>true,
117
+ :@receiver=>{:self=>{:@line=>1}},
118
+ :@check_for_local=>false}}
119
+
120
+ ruby.should parse_as(ast)
121
+ end
122
+
123
+ it 'should correctly parse "m { |a| a + x }"' do
124
+ ruby = 'm { |a| a + x }'
125
+ ast = {:send=>
126
+ {:@block=>
127
+ {:iter=>
128
+ {:@body=>
129
+ {:sendwitharguments=>
130
+ {:@block=>nil,
131
+ :@name=>:+,
132
+ :@line=>1,
133
+ :@privately=>false,
134
+ :@receiver=>
135
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>1}},
136
+ :@check_for_local=>false,
137
+ :@arguments=>
138
+ {:actualarguments=>
139
+ {:@array=>
140
+ [{:send=>
141
+ {:@block=>nil,
142
+ :@name=>:x,
143
+ :@line=>1,
144
+ :@privately=>true,
145
+ :@receiver=>{:self=>{:@line=>1}},
146
+ :@check_for_local=>false}}],
147
+ :@splat=>nil,
148
+ :@line=>1}}}},
149
+ :@line=>1,
150
+ :@arguments=>
151
+ {:iterarguments=>
152
+ {:@block=>nil,
153
+ :@arity=>1,
154
+ :@prelude=>:single,
155
+ :@optional=>0,
156
+ :@splat=>nil,
157
+ :@line=>1,
158
+ :@splat_index=>-1,
159
+ :@required_args=>1,
160
+ :@arguments=>
161
+ {:localvariableassignment=>
162
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
163
+ :@name=>:m,
164
+ :@line=>1,
165
+ :@privately=>true,
166
+ :@receiver=>{:self=>{:@line=>1}},
167
+ :@check_for_local=>false}}
168
+
169
+ ruby.should parse_as(ast)
170
+ end
171
+
172
+ it 'should correctly parse "m { |*| x }"' do
173
+ ruby = 'm { |*| x }'
174
+ ast = {:send=>
175
+ {:@block=>
176
+ {:iter=>
177
+ {:@body=>
178
+ {:send=>
179
+ {:@block=>nil,
180
+ :@name=>:x,
181
+ :@line=>1,
182
+ :@privately=>true,
183
+ :@receiver=>{:self=>{:@line=>1}},
184
+ :@check_for_local=>false}},
185
+ :@line=>1,
186
+ :@arguments=>
187
+ {:iterarguments=>
188
+ {:@block=>nil,
189
+ :@arity=>-1,
190
+ :@prelude=>:multi,
191
+ :@optional=>0,
192
+ :@splat=>nil,
193
+ :@line=>1,
194
+ :@splat_index=>-1,
195
+ :@required_args=>0,
196
+ :@arguments=>
197
+ {:masgn=>
198
+ {:@block=>nil,
199
+ :@iter_arguments=>true,
200
+ :@fixed=>false,
201
+ :@splat=>nil,
202
+ :@line=>1,
203
+ :@left=>nil,
204
+ :@right=>nil}}}}}},
205
+ :@name=>:m,
206
+ :@line=>1,
207
+ :@privately=>true,
208
+ :@receiver=>{:self=>{:@line=>1}},
209
+ :@check_for_local=>false}}
210
+
211
+ ruby.should parse_as(ast)
212
+ end
213
+
214
+ it 'should correctly parse "m { |*c| x; c }"' do
215
+ ruby = 'm { |*c| x; c }'
216
+ ast = {:send=>
217
+ {:@block=>
218
+ {:iter=>
219
+ {:@body=>
220
+ {:block=>
221
+ {:@array=>
222
+ [{:send=>
223
+ {:@block=>nil,
224
+ :@name=>:x,
225
+ :@line=>1,
226
+ :@privately=>true,
227
+ :@receiver=>{:self=>{:@line=>1}},
228
+ :@check_for_local=>false}},
229
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:c, :@line=>1}}],
230
+ :@line=>1}},
231
+ :@line=>1,
232
+ :@arguments=>
233
+ {:iterarguments=>
234
+ {:@block=>nil,
235
+ :@arity=>-1,
236
+ :@prelude=>:splat,
237
+ :@optional=>1,
238
+ :@splat=>
239
+ {:localvariableassignment=>
240
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
241
+ :@line=>1,
242
+ :@splat_index=>-1,
243
+ :@required_args=>0,
244
+ :@arguments=>
245
+ {:masgn=>
246
+ {:@block=>nil,
247
+ :@iter_arguments=>true,
248
+ :@fixed=>false,
249
+ :@splat=>
250
+ {:localvariableassignment=>
251
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
252
+ :@line=>1,
253
+ :@left=>nil,
254
+ :@right=>nil}}}}}},
255
+ :@name=>:m,
256
+ :@line=>1,
257
+ :@privately=>true,
258
+ :@receiver=>{:self=>{:@line=>1}},
259
+ :@check_for_local=>false}}
260
+
261
+ ruby.should parse_as(ast)
262
+ end
263
+
264
+ it 'should correctly parse "m { |a, | a + x }"' do
265
+ ruby = 'm { |a, | a + x }'
266
+ ast = {:send=>
267
+ {:@block=>
268
+ {:iter=>
269
+ {:@body=>
270
+ {:sendwitharguments=>
271
+ {:@block=>nil,
272
+ :@name=>:+,
273
+ :@line=>1,
274
+ :@privately=>false,
275
+ :@receiver=>
276
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>1}},
277
+ :@check_for_local=>false,
278
+ :@arguments=>
279
+ {:actualarguments=>
280
+ {:@array=>
281
+ [{:send=>
282
+ {:@block=>nil,
283
+ :@name=>:x,
284
+ :@line=>1,
285
+ :@privately=>true,
286
+ :@receiver=>{:self=>{:@line=>1}},
287
+ :@check_for_local=>false}}],
288
+ :@splat=>nil,
289
+ :@line=>1}}}},
290
+ :@line=>1,
291
+ :@arguments=>
292
+ {:iterarguments=>
293
+ {:@block=>nil,
294
+ :@arity=>1,
295
+ :@prelude=>:multi,
296
+ :@optional=>0,
297
+ :@splat=>nil,
298
+ :@line=>1,
299
+ :@splat_index=>-1,
300
+ :@required_args=>1,
301
+ :@arguments=>
302
+ {:masgn=>
303
+ {:@block=>nil,
304
+ :@iter_arguments=>true,
305
+ :@fixed=>false,
306
+ :@splat=>nil,
307
+ :@line=>1,
308
+ :@left=>
309
+ {:arrayliteral=>
310
+ {:@body=>
311
+ [{:localvariableassignment=>
312
+ {:@variable=>nil,
313
+ :@name=>:a,
314
+ :@line=>1,
315
+ :@value=>nil}}],
316
+ :@line=>1}},
317
+ :@right=>nil}}}}}},
318
+ :@name=>:m,
319
+ :@line=>1,
320
+ :@privately=>true,
321
+ :@receiver=>{:self=>{:@line=>1}},
322
+ :@check_for_local=>false}}
323
+
324
+ ruby.should parse_as(ast)
325
+ end
326
+
327
+ it 'should correctly parse "m { |a, *| a + x }"' do
328
+ ruby = 'm { |a, *| a + x }'
329
+ ast = {:send=>
330
+ {:@block=>
331
+ {:iter=>
332
+ {:@body=>
333
+ {:sendwitharguments=>
334
+ {:@block=>nil,
335
+ :@name=>:+,
336
+ :@line=>1,
337
+ :@privately=>false,
338
+ :@receiver=>
339
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>1}},
340
+ :@check_for_local=>false,
341
+ :@arguments=>
342
+ {:actualarguments=>
343
+ {:@array=>
344
+ [{:send=>
345
+ {:@block=>nil,
346
+ :@name=>:x,
347
+ :@line=>1,
348
+ :@privately=>true,
349
+ :@receiver=>{:self=>{:@line=>1}},
350
+ :@check_for_local=>false}}],
351
+ :@splat=>nil,
352
+ :@line=>1}}}},
353
+ :@line=>1,
354
+ :@arguments=>
355
+ {:iterarguments=>
356
+ {:@block=>nil,
357
+ :@arity=>1,
358
+ :@prelude=>:multi,
359
+ :@optional=>0,
360
+ :@splat=>nil,
361
+ :@line=>1,
362
+ :@splat_index=>-1,
363
+ :@required_args=>1,
364
+ :@arguments=>
365
+ {:masgn=>
366
+ {:@block=>nil,
367
+ :@iter_arguments=>true,
368
+ :@fixed=>false,
369
+ :@splat=>nil,
370
+ :@line=>1,
371
+ :@left=>
372
+ {:arrayliteral=>
373
+ {:@body=>
374
+ [{:localvariableassignment=>
375
+ {:@variable=>nil,
376
+ :@name=>:a,
377
+ :@line=>1,
378
+ :@value=>nil}}],
379
+ :@line=>1}},
380
+ :@right=>nil}}}}}},
381
+ :@name=>:m,
382
+ :@line=>1,
383
+ :@privately=>true,
384
+ :@receiver=>{:self=>{:@line=>1}},
385
+ :@check_for_local=>false}}
386
+
387
+ ruby.should parse_as(ast)
388
+ end
389
+
390
+ it 'should correctly parse "m { |a, *c| a + x; c }"' do
391
+ ruby = 'm { |a, *c| a + x; c }'
392
+ ast = {:send=>
393
+ {:@block=>
394
+ {:iter=>
395
+ {:@body=>
396
+ {:block=>
397
+ {:@array=>
398
+ [{:sendwitharguments=>
399
+ {:@block=>nil,
400
+ :@name=>:+,
401
+ :@line=>1,
402
+ :@privately=>false,
403
+ :@receiver=>
404
+ {:localvariableaccess=>
405
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
406
+ :@check_for_local=>false,
407
+ :@arguments=>
408
+ {:actualarguments=>
409
+ {:@array=>
410
+ [{:send=>
411
+ {:@block=>nil,
412
+ :@name=>:x,
413
+ :@line=>1,
414
+ :@privately=>true,
415
+ :@receiver=>{:self=>{:@line=>1}},
416
+ :@check_for_local=>false}}],
417
+ :@splat=>nil,
418
+ :@line=>1}}}},
419
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:c, :@line=>1}}],
420
+ :@line=>1}},
421
+ :@line=>1,
422
+ :@arguments=>
423
+ {:iterarguments=>
424
+ {:@block=>nil,
425
+ :@arity=>-2,
426
+ :@prelude=>:multi,
427
+ :@optional=>1,
428
+ :@splat=>
429
+ {:localvariableassignment=>
430
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
431
+ :@line=>1,
432
+ :@splat_index=>-1,
433
+ :@required_args=>1,
434
+ :@arguments=>
435
+ {:masgn=>
436
+ {:@block=>nil,
437
+ :@iter_arguments=>true,
438
+ :@fixed=>false,
439
+ :@splat=>
440
+ {:localvariableassignment=>
441
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
442
+ :@line=>1,
443
+ :@left=>
444
+ {:arrayliteral=>
445
+ {:@body=>
446
+ [{:localvariableassignment=>
447
+ {:@variable=>nil,
448
+ :@name=>:a,
449
+ :@line=>1,
450
+ :@value=>nil}}],
451
+ :@line=>1}},
452
+ :@right=>nil}}}}}},
453
+ :@name=>:m,
454
+ :@line=>1,
455
+ :@privately=>true,
456
+ :@receiver=>{:self=>{:@line=>1}},
457
+ :@check_for_local=>false}}
458
+
459
+ ruby.should parse_as(ast)
460
+ end
461
+
462
+ it 'should correctly parse "m { |a, b| a + x; b }"' do
463
+ ruby = 'm { |a, b| a + x; b }'
464
+ ast = {:send=>
465
+ {:@block=>
466
+ {:iter=>
467
+ {:@body=>
468
+ {:block=>
469
+ {:@array=>
470
+ [{:sendwitharguments=>
471
+ {:@block=>nil,
472
+ :@name=>:+,
473
+ :@line=>1,
474
+ :@privately=>false,
475
+ :@receiver=>
476
+ {:localvariableaccess=>
477
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
478
+ :@check_for_local=>false,
479
+ :@arguments=>
480
+ {:actualarguments=>
481
+ {:@array=>
482
+ [{:send=>
483
+ {:@block=>nil,
484
+ :@name=>:x,
485
+ :@line=>1,
486
+ :@privately=>true,
487
+ :@receiver=>{:self=>{:@line=>1}},
488
+ :@check_for_local=>false}}],
489
+ :@splat=>nil,
490
+ :@line=>1}}}},
491
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:b, :@line=>1}}],
492
+ :@line=>1}},
493
+ :@line=>1,
494
+ :@arguments=>
495
+ {:iterarguments=>
496
+ {:@block=>nil,
497
+ :@arity=>2,
498
+ :@prelude=>:multi,
499
+ :@optional=>0,
500
+ :@splat=>nil,
501
+ :@line=>1,
502
+ :@splat_index=>-1,
503
+ :@required_args=>2,
504
+ :@arguments=>
505
+ {:masgn=>
506
+ {:@block=>nil,
507
+ :@iter_arguments=>true,
508
+ :@fixed=>false,
509
+ :@splat=>nil,
510
+ :@line=>1,
511
+ :@left=>
512
+ {:arrayliteral=>
513
+ {:@body=>
514
+ [{:localvariableassignment=>
515
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
516
+ {:localvariableassignment=>
517
+ {:@variable=>nil,
518
+ :@name=>:b,
519
+ :@line=>1,
520
+ :@value=>nil}}],
521
+ :@line=>1}},
522
+ :@right=>nil}}}}}},
523
+ :@name=>:m,
524
+ :@line=>1,
525
+ :@privately=>true,
526
+ :@receiver=>{:self=>{:@line=>1}},
527
+ :@check_for_local=>false}}
528
+
529
+ ruby.should parse_as(ast)
530
+ end
531
+
532
+ it 'should correctly parse "m { |a, b, | a + x; b }"' do
533
+ ruby = 'm { |a, b, | a + x; b }'
534
+ ast = {:send=>
535
+ {:@block=>
536
+ {:iter=>
537
+ {:@body=>
538
+ {:block=>
539
+ {:@array=>
540
+ [{:sendwitharguments=>
541
+ {:@block=>nil,
542
+ :@name=>:+,
543
+ :@line=>1,
544
+ :@privately=>false,
545
+ :@receiver=>
546
+ {:localvariableaccess=>
547
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
548
+ :@check_for_local=>false,
549
+ :@arguments=>
550
+ {:actualarguments=>
551
+ {:@array=>
552
+ [{:send=>
553
+ {:@block=>nil,
554
+ :@name=>:x,
555
+ :@line=>1,
556
+ :@privately=>true,
557
+ :@receiver=>{:self=>{:@line=>1}},
558
+ :@check_for_local=>false}}],
559
+ :@splat=>nil,
560
+ :@line=>1}}}},
561
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:b, :@line=>1}}],
562
+ :@line=>1}},
563
+ :@line=>1,
564
+ :@arguments=>
565
+ {:iterarguments=>
566
+ {:@block=>nil,
567
+ :@arity=>2,
568
+ :@prelude=>:multi,
569
+ :@optional=>0,
570
+ :@splat=>nil,
571
+ :@line=>1,
572
+ :@splat_index=>-1,
573
+ :@required_args=>2,
574
+ :@arguments=>
575
+ {:masgn=>
576
+ {:@block=>nil,
577
+ :@iter_arguments=>true,
578
+ :@fixed=>false,
579
+ :@splat=>nil,
580
+ :@line=>1,
581
+ :@left=>
582
+ {:arrayliteral=>
583
+ {:@body=>
584
+ [{:localvariableassignment=>
585
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
586
+ {:localvariableassignment=>
587
+ {:@variable=>nil,
588
+ :@name=>:b,
589
+ :@line=>1,
590
+ :@value=>nil}}],
591
+ :@line=>1}},
592
+ :@right=>nil}}}}}},
593
+ :@name=>:m,
594
+ :@line=>1,
595
+ :@privately=>true,
596
+ :@receiver=>{:self=>{:@line=>1}},
597
+ :@check_for_local=>false}}
598
+
599
+ ruby.should parse_as(ast)
600
+ end
601
+
602
+ it 'should correctly parse "m { |a, b, *| a + x; b }"' do
603
+ ruby = 'm { |a, b, *| a + x; b }'
604
+ ast = {:send=>
605
+ {:@block=>
606
+ {:iter=>
607
+ {:@body=>
608
+ {:block=>
609
+ {:@array=>
610
+ [{:sendwitharguments=>
611
+ {:@block=>nil,
612
+ :@name=>:+,
613
+ :@line=>1,
614
+ :@privately=>false,
615
+ :@receiver=>
616
+ {:localvariableaccess=>
617
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
618
+ :@check_for_local=>false,
619
+ :@arguments=>
620
+ {:actualarguments=>
621
+ {:@array=>
622
+ [{:send=>
623
+ {:@block=>nil,
624
+ :@name=>:x,
625
+ :@line=>1,
626
+ :@privately=>true,
627
+ :@receiver=>{:self=>{:@line=>1}},
628
+ :@check_for_local=>false}}],
629
+ :@splat=>nil,
630
+ :@line=>1}}}},
631
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:b, :@line=>1}}],
632
+ :@line=>1}},
633
+ :@line=>1,
634
+ :@arguments=>
635
+ {:iterarguments=>
636
+ {:@block=>nil,
637
+ :@arity=>2,
638
+ :@prelude=>:multi,
639
+ :@optional=>0,
640
+ :@splat=>nil,
641
+ :@line=>1,
642
+ :@splat_index=>-1,
643
+ :@required_args=>2,
644
+ :@arguments=>
645
+ {:masgn=>
646
+ {:@block=>nil,
647
+ :@iter_arguments=>true,
648
+ :@fixed=>false,
649
+ :@splat=>nil,
650
+ :@line=>1,
651
+ :@left=>
652
+ {:arrayliteral=>
653
+ {:@body=>
654
+ [{:localvariableassignment=>
655
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
656
+ {:localvariableassignment=>
657
+ {:@variable=>nil,
658
+ :@name=>:b,
659
+ :@line=>1,
660
+ :@value=>nil}}],
661
+ :@line=>1}},
662
+ :@right=>nil}}}}}},
663
+ :@name=>:m,
664
+ :@line=>1,
665
+ :@privately=>true,
666
+ :@receiver=>{:self=>{:@line=>1}},
667
+ :@check_for_local=>false}}
668
+
669
+ ruby.should parse_as(ast)
670
+ end
671
+
672
+ it 'should correctly parse "m { |a, b, *c| a + x; b; c }"' do
673
+ ruby = 'm { |a, b, *c| a + x; b; c }'
674
+ ast = {:send=>
675
+ {:@block=>
676
+ {:iter=>
677
+ {:@body=>
678
+ {:block=>
679
+ {:@array=>
680
+ [{:sendwitharguments=>
681
+ {:@block=>nil,
682
+ :@name=>:+,
683
+ :@line=>1,
684
+ :@privately=>false,
685
+ :@receiver=>
686
+ {:localvariableaccess=>
687
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
688
+ :@check_for_local=>false,
689
+ :@arguments=>
690
+ {:actualarguments=>
691
+ {:@array=>
692
+ [{:send=>
693
+ {:@block=>nil,
694
+ :@name=>:x,
695
+ :@line=>1,
696
+ :@privately=>true,
697
+ :@receiver=>{:self=>{:@line=>1}},
698
+ :@check_for_local=>false}}],
699
+ :@splat=>nil,
700
+ :@line=>1}}}},
701
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:b, :@line=>1}},
702
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:c, :@line=>1}}],
703
+ :@line=>1}},
704
+ :@line=>1,
705
+ :@arguments=>
706
+ {:iterarguments=>
707
+ {:@block=>nil,
708
+ :@arity=>-3,
709
+ :@prelude=>:multi,
710
+ :@optional=>1,
711
+ :@splat=>
712
+ {:localvariableassignment=>
713
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
714
+ :@line=>1,
715
+ :@splat_index=>-1,
716
+ :@required_args=>2,
717
+ :@arguments=>
718
+ {:masgn=>
719
+ {:@block=>nil,
720
+ :@iter_arguments=>true,
721
+ :@fixed=>false,
722
+ :@splat=>
723
+ {:localvariableassignment=>
724
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
725
+ :@line=>1,
726
+ :@left=>
727
+ {:arrayliteral=>
728
+ {:@body=>
729
+ [{:localvariableassignment=>
730
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
731
+ {:localvariableassignment=>
732
+ {:@variable=>nil,
733
+ :@name=>:b,
734
+ :@line=>1,
735
+ :@value=>nil}}],
736
+ :@line=>1}},
737
+ :@right=>nil}}}}}},
738
+ :@name=>:m,
739
+ :@line=>1,
740
+ :@privately=>true,
741
+ :@receiver=>{:self=>{:@line=>1}},
742
+ :@check_for_local=>false}}
743
+
744
+ ruby.should parse_as(ast)
745
+ end
746
+
747
+ it 'should correctly parse "m do |a, b, *c| a + x; b; c end"' do
748
+ ruby = 'm do |a, b, *c| a + x; b; c end'
749
+ ast = {:send=>
750
+ {:@block=>
751
+ {:iter=>
752
+ {:@body=>
753
+ {:block=>
754
+ {:@array=>
755
+ [{:sendwitharguments=>
756
+ {:@block=>nil,
757
+ :@name=>:+,
758
+ :@line=>1,
759
+ :@privately=>false,
760
+ :@receiver=>
761
+ {:localvariableaccess=>
762
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
763
+ :@check_for_local=>false,
764
+ :@arguments=>
765
+ {:actualarguments=>
766
+ {:@array=>
767
+ [{:send=>
768
+ {:@block=>nil,
769
+ :@name=>:x,
770
+ :@line=>1,
771
+ :@privately=>true,
772
+ :@receiver=>{:self=>{:@line=>1}},
773
+ :@check_for_local=>false}}],
774
+ :@splat=>nil,
775
+ :@line=>1}}}},
776
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:b, :@line=>1}},
777
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:c, :@line=>1}}],
778
+ :@line=>1}},
779
+ :@line=>1,
780
+ :@arguments=>
781
+ {:iterarguments=>
782
+ {:@block=>nil,
783
+ :@arity=>-3,
784
+ :@prelude=>:multi,
785
+ :@optional=>1,
786
+ :@splat=>
787
+ {:localvariableassignment=>
788
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
789
+ :@line=>1,
790
+ :@splat_index=>-1,
791
+ :@required_args=>2,
792
+ :@arguments=>
793
+ {:masgn=>
794
+ {:@block=>nil,
795
+ :@iter_arguments=>true,
796
+ :@fixed=>false,
797
+ :@splat=>
798
+ {:localvariableassignment=>
799
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
800
+ :@line=>1,
801
+ :@left=>
802
+ {:arrayliteral=>
803
+ {:@body=>
804
+ [{:localvariableassignment=>
805
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
806
+ {:localvariableassignment=>
807
+ {:@variable=>nil,
808
+ :@name=>:b,
809
+ :@line=>1,
810
+ :@value=>nil}}],
811
+ :@line=>1}},
812
+ :@right=>nil}}}}}},
813
+ :@name=>:m,
814
+ :@line=>1,
815
+ :@privately=>true,
816
+ :@receiver=>{:self=>{:@line=>1}},
817
+ :@check_for_local=>false}}
818
+
819
+ ruby.should parse_as(ast)
820
+ end
821
+
822
+ it 'should correctly parse "m { n = 1; m { n } }"' do
823
+ ruby = 'm { n = 1; m { n } }'
824
+ ast = {:send=>
825
+ {:@block=>
826
+ {:iter=>
827
+ {:@body=>
828
+ {:block=>
829
+ {:@array=>
830
+ [{:localvariableassignment=>
831
+ {:@variable=>nil,
832
+ :@name=>:n,
833
+ :@line=>1,
834
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
835
+ {:send=>
836
+ {:@block=>
837
+ {:iter=>
838
+ {:@body=>
839
+ {:localvariableaccess=>
840
+ {:@variable=>nil, :@name=>:n, :@line=>1}},
841
+ :@line=>1,
842
+ :@arguments=>
843
+ {:iterarguments=>
844
+ {:@block=>nil,
845
+ :@arity=>-1,
846
+ :@prelude=>nil,
847
+ :@optional=>0,
848
+ :@splat=>nil,
849
+ :@line=>1,
850
+ :@splat_index=>-2,
851
+ :@required_args=>0}}}},
852
+ :@name=>:m,
853
+ :@line=>1,
854
+ :@privately=>true,
855
+ :@receiver=>{:self=>{:@line=>1}},
856
+ :@check_for_local=>false}}],
857
+ :@line=>1}},
858
+ :@line=>1,
859
+ :@arguments=>
860
+ {:iterarguments=>
861
+ {:@block=>nil,
862
+ :@arity=>-1,
863
+ :@prelude=>nil,
864
+ :@optional=>0,
865
+ :@splat=>nil,
866
+ :@line=>1,
867
+ :@splat_index=>-2,
868
+ :@required_args=>0}}}},
869
+ :@name=>:m,
870
+ :@line=>1,
871
+ :@privately=>true,
872
+ :@receiver=>{:self=>{:@line=>1}},
873
+ :@check_for_local=>false}}
874
+
875
+ ruby.should parse_as(ast)
876
+ end
877
+
878
+ it 'should correctly parse "n = 1; m { n = 2 }; n"' do
879
+ ruby = 'n = 1; m { n = 2 }; n'
880
+ ast = {:block=>
881
+ {:@array=>
882
+ [{:localvariableassignment=>
883
+ {:@variable=>nil,
884
+ :@name=>:n,
885
+ :@line=>1,
886
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
887
+ {:send=>
888
+ {:@block=>
889
+ {:iter=>
890
+ {:@body=>
891
+ {:localvariableassignment=>
892
+ {:@variable=>nil,
893
+ :@name=>:n,
894
+ :@line=>1,
895
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>2}}}},
896
+ :@line=>1,
897
+ :@arguments=>
898
+ {:iterarguments=>
899
+ {:@block=>nil,
900
+ :@arity=>-1,
901
+ :@prelude=>nil,
902
+ :@optional=>0,
903
+ :@splat=>nil,
904
+ :@line=>1,
905
+ :@splat_index=>-2,
906
+ :@required_args=>0}}}},
907
+ :@name=>:m,
908
+ :@line=>1,
909
+ :@privately=>true,
910
+ :@receiver=>{:self=>{:@line=>1}},
911
+ :@check_for_local=>false}},
912
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:n, :@line=>1}}],
913
+ :@line=>1}}
914
+
915
+ ruby.should parse_as(ast)
916
+ end
917
+
918
+ it 'should correctly parse "m(a) { |b| a + x }"' do
919
+ ruby = 'm(a) { |b| a + x }'
920
+ ast = {:sendwitharguments=>
921
+ {:@block=>
922
+ {:iter=>
923
+ {:@body=>
924
+ {:sendwitharguments=>
925
+ {:@block=>nil,
926
+ :@name=>:+,
927
+ :@line=>1,
928
+ :@privately=>false,
929
+ :@receiver=>
930
+ {:send=>
931
+ {:@block=>nil,
932
+ :@name=>:a,
933
+ :@line=>1,
934
+ :@privately=>true,
935
+ :@receiver=>{:self=>{:@line=>1}},
936
+ :@check_for_local=>false}},
937
+ :@check_for_local=>false,
938
+ :@arguments=>
939
+ {:actualarguments=>
940
+ {:@array=>
941
+ [{:send=>
942
+ {:@block=>nil,
943
+ :@name=>:x,
944
+ :@line=>1,
945
+ :@privately=>true,
946
+ :@receiver=>{:self=>{:@line=>1}},
947
+ :@check_for_local=>false}}],
948
+ :@splat=>nil,
949
+ :@line=>1}}}},
950
+ :@line=>1,
951
+ :@arguments=>
952
+ {:iterarguments=>
953
+ {:@block=>nil,
954
+ :@arity=>1,
955
+ :@prelude=>:single,
956
+ :@optional=>0,
957
+ :@splat=>nil,
958
+ :@line=>1,
959
+ :@splat_index=>-1,
960
+ :@required_args=>1,
961
+ :@arguments=>
962
+ {:localvariableassignment=>
963
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}}}}},
964
+ :@name=>:m,
965
+ :@line=>1,
966
+ :@privately=>true,
967
+ :@receiver=>{:self=>{:@line=>1}},
968
+ :@check_for_local=>false,
969
+ :@arguments=>
970
+ {:actualarguments=>
971
+ {:@array=>
972
+ [{:send=>
973
+ {:@block=>nil,
974
+ :@name=>:a,
975
+ :@line=>1,
976
+ :@privately=>true,
977
+ :@receiver=>{:self=>{:@line=>1}},
978
+ :@check_for_local=>false}}],
979
+ :@splat=>nil,
980
+ :@line=>1}}}}
981
+
982
+ ruby.should parse_as(ast)
983
+ end
984
+
985
+ it 'should correctly parse "m { |a| a + x }"' do
986
+ ruby = <<-ruby
987
+ m { |a|
988
+ a + x
989
+ }
990
+ ruby
991
+ ast = {:send=>
992
+ {:@block=>
993
+ {:iter=>
994
+ {:@body=>
995
+ {:sendwitharguments=>
996
+ {:@block=>nil,
997
+ :@name=>:+,
998
+ :@line=>2,
999
+ :@privately=>false,
1000
+ :@receiver=>
1001
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>2}},
1002
+ :@check_for_local=>false,
1003
+ :@arguments=>
1004
+ {:actualarguments=>
1005
+ {:@array=>
1006
+ [{:send=>
1007
+ {:@block=>nil,
1008
+ :@name=>:x,
1009
+ :@line=>2,
1010
+ :@privately=>true,
1011
+ :@receiver=>{:self=>{:@line=>2}},
1012
+ :@check_for_local=>false}}],
1013
+ :@splat=>nil,
1014
+ :@line=>2}}}},
1015
+ :@line=>1,
1016
+ :@arguments=>
1017
+ {:iterarguments=>
1018
+ {:@block=>nil,
1019
+ :@arity=>1,
1020
+ :@prelude=>:single,
1021
+ :@optional=>0,
1022
+ :@splat=>nil,
1023
+ :@line=>1,
1024
+ :@splat_index=>-1,
1025
+ :@required_args=>1,
1026
+ :@arguments=>
1027
+ {:localvariableassignment=>
1028
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
1029
+ :@name=>:m,
1030
+ :@line=>1,
1031
+ :@privately=>true,
1032
+ :@receiver=>{:self=>{:@line=>1}},
1033
+ :@check_for_local=>false}}
1034
+
1035
+ ruby.should parse_as(ast)
1036
+ end
1037
+
1038
+ it 'should correctly parse "m do |a| a + x end"' do
1039
+ ruby = <<-ruby
1040
+ m do |a|
1041
+ a + x
1042
+ end
1043
+ ruby
1044
+ ast = {:send=>
1045
+ {:@block=>
1046
+ {:iter=>
1047
+ {:@body=>
1048
+ {:sendwitharguments=>
1049
+ {:@block=>nil,
1050
+ :@name=>:+,
1051
+ :@line=>2,
1052
+ :@privately=>false,
1053
+ :@receiver=>
1054
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>2}},
1055
+ :@check_for_local=>false,
1056
+ :@arguments=>
1057
+ {:actualarguments=>
1058
+ {:@array=>
1059
+ [{:send=>
1060
+ {:@block=>nil,
1061
+ :@name=>:x,
1062
+ :@line=>2,
1063
+ :@privately=>true,
1064
+ :@receiver=>{:self=>{:@line=>2}},
1065
+ :@check_for_local=>false}}],
1066
+ :@splat=>nil,
1067
+ :@line=>2}}}},
1068
+ :@line=>1,
1069
+ :@arguments=>
1070
+ {:iterarguments=>
1071
+ {:@block=>nil,
1072
+ :@arity=>1,
1073
+ :@prelude=>:single,
1074
+ :@optional=>0,
1075
+ :@splat=>nil,
1076
+ :@line=>1,
1077
+ :@splat_index=>-1,
1078
+ :@required_args=>1,
1079
+ :@arguments=>
1080
+ {:localvariableassignment=>
1081
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
1082
+ :@name=>:m,
1083
+ :@line=>1,
1084
+ :@privately=>true,
1085
+ :@receiver=>{:self=>{:@line=>1}},
1086
+ :@check_for_local=>false}}
1087
+
1088
+ ruby.should parse_as(ast)
1089
+ end
1090
+
1091
+ it 'should correctly parse "obj.m { |a| a + x }"' do
1092
+ ruby = 'obj.m { |a| a + x }'
1093
+ ast = {:send=>
1094
+ {:@block=>
1095
+ {:iter=>
1096
+ {:@body=>
1097
+ {:sendwitharguments=>
1098
+ {:@block=>nil,
1099
+ :@name=>:+,
1100
+ :@line=>1,
1101
+ :@privately=>false,
1102
+ :@receiver=>
1103
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>1}},
1104
+ :@check_for_local=>false,
1105
+ :@arguments=>
1106
+ {:actualarguments=>
1107
+ {:@array=>
1108
+ [{:send=>
1109
+ {:@block=>nil,
1110
+ :@name=>:x,
1111
+ :@line=>1,
1112
+ :@privately=>true,
1113
+ :@receiver=>{:self=>{:@line=>1}},
1114
+ :@check_for_local=>false}}],
1115
+ :@splat=>nil,
1116
+ :@line=>1}}}},
1117
+ :@line=>1,
1118
+ :@arguments=>
1119
+ {:iterarguments=>
1120
+ {:@block=>nil,
1121
+ :@arity=>1,
1122
+ :@prelude=>:single,
1123
+ :@optional=>0,
1124
+ :@splat=>nil,
1125
+ :@line=>1,
1126
+ :@splat_index=>-1,
1127
+ :@required_args=>1,
1128
+ :@arguments=>
1129
+ {:localvariableassignment=>
1130
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
1131
+ :@name=>:m,
1132
+ :@line=>1,
1133
+ :@privately=>false,
1134
+ :@receiver=>
1135
+ {:send=>
1136
+ {:@block=>nil,
1137
+ :@name=>:obj,
1138
+ :@line=>1,
1139
+ :@privately=>true,
1140
+ :@receiver=>{:self=>{:@line=>1}},
1141
+ :@check_for_local=>false}},
1142
+ :@check_for_local=>false}}
1143
+
1144
+ ruby.should parse_as(ast)
1145
+ end
1146
+
1147
+ it 'should correctly parse "obj.m(x) { |a| a + x }"' do
1148
+ ruby = 'obj.m(x) { |a| a + x }'
1149
+ ast = {:sendwitharguments=>
1150
+ {:@block=>
1151
+ {:iter=>
1152
+ {:@body=>
1153
+ {:sendwitharguments=>
1154
+ {:@block=>nil,
1155
+ :@name=>:+,
1156
+ :@line=>1,
1157
+ :@privately=>false,
1158
+ :@receiver=>
1159
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>1}},
1160
+ :@check_for_local=>false,
1161
+ :@arguments=>
1162
+ {:actualarguments=>
1163
+ {:@array=>
1164
+ [{:send=>
1165
+ {:@block=>nil,
1166
+ :@name=>:x,
1167
+ :@line=>1,
1168
+ :@privately=>true,
1169
+ :@receiver=>{:self=>{:@line=>1}},
1170
+ :@check_for_local=>false}}],
1171
+ :@splat=>nil,
1172
+ :@line=>1}}}},
1173
+ :@line=>1,
1174
+ :@arguments=>
1175
+ {:iterarguments=>
1176
+ {:@block=>nil,
1177
+ :@arity=>1,
1178
+ :@prelude=>:single,
1179
+ :@optional=>0,
1180
+ :@splat=>nil,
1181
+ :@line=>1,
1182
+ :@splat_index=>-1,
1183
+ :@required_args=>1,
1184
+ :@arguments=>
1185
+ {:localvariableassignment=>
1186
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
1187
+ :@name=>:m,
1188
+ :@line=>1,
1189
+ :@privately=>false,
1190
+ :@receiver=>
1191
+ {:send=>
1192
+ {:@block=>nil,
1193
+ :@name=>:obj,
1194
+ :@line=>1,
1195
+ :@privately=>true,
1196
+ :@receiver=>{:self=>{:@line=>1}},
1197
+ :@check_for_local=>false}},
1198
+ :@check_for_local=>false,
1199
+ :@arguments=>
1200
+ {:actualarguments=>
1201
+ {:@array=>
1202
+ [{:send=>
1203
+ {:@block=>nil,
1204
+ :@name=>:x,
1205
+ :@line=>1,
1206
+ :@privately=>true,
1207
+ :@receiver=>{:self=>{:@line=>1}},
1208
+ :@check_for_local=>false}}],
1209
+ :@splat=>nil,
1210
+ :@line=>1}}}}
1211
+
1212
+ ruby.should parse_as(ast)
1213
+ end
1214
+
1215
+ it 'should correctly parse "obj.m(a) { |a| a + x }"' do
1216
+ ruby = 'obj.m(a) { |a| a + x }'
1217
+ ast = {:sendwitharguments=>
1218
+ {:@block=>
1219
+ {:iter=>
1220
+ {:@body=>
1221
+ {:sendwitharguments=>
1222
+ {:@block=>nil,
1223
+ :@name=>:+,
1224
+ :@line=>1,
1225
+ :@privately=>false,
1226
+ :@receiver=>
1227
+ {:localvariableaccess=>{:@variable=>nil, :@name=>:a, :@line=>1}},
1228
+ :@check_for_local=>false,
1229
+ :@arguments=>
1230
+ {:actualarguments=>
1231
+ {:@array=>
1232
+ [{:send=>
1233
+ {:@block=>nil,
1234
+ :@name=>:x,
1235
+ :@line=>1,
1236
+ :@privately=>true,
1237
+ :@receiver=>{:self=>{:@line=>1}},
1238
+ :@check_for_local=>false}}],
1239
+ :@splat=>nil,
1240
+ :@line=>1}}}},
1241
+ :@line=>1,
1242
+ :@arguments=>
1243
+ {:iterarguments=>
1244
+ {:@block=>nil,
1245
+ :@arity=>1,
1246
+ :@prelude=>:single,
1247
+ :@optional=>0,
1248
+ :@splat=>nil,
1249
+ :@line=>1,
1250
+ :@splat_index=>-1,
1251
+ :@required_args=>1,
1252
+ :@arguments=>
1253
+ {:localvariableassignment=>
1254
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
1255
+ :@name=>:m,
1256
+ :@line=>1,
1257
+ :@privately=>false,
1258
+ :@receiver=>
1259
+ {:send=>
1260
+ {:@block=>nil,
1261
+ :@name=>:obj,
1262
+ :@line=>1,
1263
+ :@privately=>true,
1264
+ :@receiver=>{:self=>{:@line=>1}},
1265
+ :@check_for_local=>false}},
1266
+ :@check_for_local=>false,
1267
+ :@arguments=>
1268
+ {:actualarguments=>
1269
+ {:@array=>
1270
+ [{:send=>
1271
+ {:@block=>nil,
1272
+ :@name=>:a,
1273
+ :@line=>1,
1274
+ :@privately=>true,
1275
+ :@receiver=>{:self=>{:@line=>1}},
1276
+ :@check_for_local=>false}}],
1277
+ :@splat=>nil,
1278
+ :@line=>1}}}}
1279
+
1280
+ ruby.should parse_as(ast)
1281
+ end
1282
+
1283
+ it 'should correctly parse "a = 1; m { |a| a + x }"' do
1284
+ ruby = 'a = 1; m { |a| a + x }'
1285
+ ast = {:block=>
1286
+ {:@array=>
1287
+ [{:localvariableassignment=>
1288
+ {:@variable=>nil,
1289
+ :@name=>:a,
1290
+ :@line=>1,
1291
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
1292
+ {:send=>
1293
+ {:@block=>
1294
+ {:iter=>
1295
+ {:@body=>
1296
+ {:sendwitharguments=>
1297
+ {:@block=>nil,
1298
+ :@name=>:+,
1299
+ :@line=>1,
1300
+ :@privately=>false,
1301
+ :@receiver=>
1302
+ {:localvariableaccess=>
1303
+ {:@variable=>nil, :@name=>:a, :@line=>1}},
1304
+ :@check_for_local=>false,
1305
+ :@arguments=>
1306
+ {:actualarguments=>
1307
+ {:@array=>
1308
+ [{:send=>
1309
+ {:@block=>nil,
1310
+ :@name=>:x,
1311
+ :@line=>1,
1312
+ :@privately=>true,
1313
+ :@receiver=>{:self=>{:@line=>1}},
1314
+ :@check_for_local=>false}}],
1315
+ :@splat=>nil,
1316
+ :@line=>1}}}},
1317
+ :@line=>1,
1318
+ :@arguments=>
1319
+ {:iterarguments=>
1320
+ {:@block=>nil,
1321
+ :@arity=>1,
1322
+ :@prelude=>:single,
1323
+ :@optional=>0,
1324
+ :@splat=>nil,
1325
+ :@line=>1,
1326
+ :@splat_index=>-1,
1327
+ :@required_args=>1,
1328
+ :@arguments=>
1329
+ {:localvariableassignment=>
1330
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}}}},
1331
+ :@name=>:m,
1332
+ :@line=>1,
1333
+ :@privately=>true,
1334
+ :@receiver=>{:self=>{:@line=>1}},
1335
+ :@check_for_local=>false}}],
1336
+ :@line=>1}}
1337
+
1338
+ ruby.should parse_as(ast)
1339
+ end
1340
+
1341
+ it 'should correctly parse "do ... begin ... rescue ..."' do
1342
+ ruby = <<-ruby
1343
+ x = nil
1344
+ m do |a|
1345
+ begin
1346
+ x
1347
+ rescue Exception => x
1348
+ break
1349
+ ensure
1350
+ x = a
1351
+ end
1352
+ end
1353
+ ruby
1354
+ ast = {:block=>
1355
+ {:@array=>
1356
+ [{:localvariableassignment=>
1357
+ {:@variable=>nil, :@name=>:x, :@line=>1, :@value=>{}}},
1358
+ {:send=>
1359
+ {:@block=>
1360
+ {:iter=>
1361
+ {:@body=>
1362
+ {:begin=>
1363
+ {:@rescue=>
1364
+ {:ensure=>
1365
+ {:@ensure=>
1366
+ {:localvariableassignment=>
1367
+ {:@variable=>nil,
1368
+ :@name=>:x,
1369
+ :@line=>8,
1370
+ :@value=>
1371
+ {:localvariableaccess=>
1372
+ {:@variable=>nil, :@name=>:a, :@line=>8}}}},
1373
+ :@body=>
1374
+ {:rescue=>
1375
+ {:@body=>
1376
+ {:localvariableaccess=>
1377
+ {:@variable=>nil, :@name=>:x, :@line=>4}},
1378
+ :@rescue=>
1379
+ {:rescuecondition=>
1380
+ {:@conditions=>
1381
+ {:arrayliteral=>
1382
+ {:@body=>
1383
+ [{:constfind=>
1384
+ {:@name=>:Exception, :@line=>5}}],
1385
+ :@line=>5}},
1386
+ :@body=>
1387
+ {:block=>
1388
+ {:@array=>[{:break=>{:@line=>6, :@value=>{}}}],
1389
+ :@line=>5}},
1390
+ :@splat=>nil,
1391
+ :@next=>nil,
1392
+ :@line=>5,
1393
+ :@assignment=>
1394
+ {:localvariableassignment=>
1395
+ {:@variable=>nil,
1396
+ :@name=>:x,
1397
+ :@line=>5,
1398
+ :@value=>
1399
+ {:globalvariableaccess=>
1400
+ {:@name=>:$!, :@line=>7}}}}}},
1401
+ :@else=>nil,
1402
+ :@line=>9}},
1403
+ :@line=>4}},
1404
+ :@line=>3}},
1405
+ :@line=>2,
1406
+ :@arguments=>
1407
+ {:iterarguments=>
1408
+ {:@block=>nil,
1409
+ :@arity=>1,
1410
+ :@prelude=>:single,
1411
+ :@optional=>0,
1412
+ :@splat=>nil,
1413
+ :@line=>2,
1414
+ :@splat_index=>-1,
1415
+ :@required_args=>1,
1416
+ :@arguments=>
1417
+ {:localvariableassignment=>
1418
+ {:@variable=>nil, :@name=>:a, :@line=>2, :@value=>nil}}}}}},
1419
+ :@name=>:m,
1420
+ :@line=>2,
1421
+ :@privately=>true,
1422
+ :@receiver=>{:self=>{:@line=>2}},
1423
+ :@check_for_local=>false}}],
1424
+ :@line=>1}}
1425
+
1426
+ ruby.should parse_as(ast)
1427
+ end
1428
+
1429
+ it 'should correctly parse "m { next }"' do
1430
+ ruby = 'm { next }'
1431
+ ast = {:send=>
1432
+ {:@block=>
1433
+ {:iter=>
1434
+ {:@body=>{:next=>{:@line=>1, :@value=>nil}},
1435
+ :@line=>1,
1436
+ :@arguments=>
1437
+ {:iterarguments=>
1438
+ {:@block=>nil,
1439
+ :@arity=>-1,
1440
+ :@prelude=>nil,
1441
+ :@optional=>0,
1442
+ :@splat=>nil,
1443
+ :@line=>1,
1444
+ :@splat_index=>-2,
1445
+ :@required_args=>0}}}},
1446
+ :@name=>:m,
1447
+ :@line=>1,
1448
+ :@privately=>true,
1449
+ :@receiver=>{:self=>{:@line=>1}},
1450
+ :@check_for_local=>false}}
1451
+
1452
+ ruby.should parse_as(ast)
1453
+ end
1454
+
1455
+ it 'should correctly parse "m { next if x }"' do
1456
+ ruby = 'm { next if x }'
1457
+ ast = {:send=>
1458
+ {:@block=>
1459
+ {:iter=>
1460
+ {:@body=>
1461
+ {:if=>
1462
+ {:@body=>{:next=>{:@line=>1, :@value=>nil}},
1463
+ :@condition=>
1464
+ {:send=>
1465
+ {:@block=>nil,
1466
+ :@name=>:x,
1467
+ :@line=>1,
1468
+ :@privately=>true,
1469
+ :@receiver=>{:self=>{:@line=>1}},
1470
+ :@check_for_local=>false}},
1471
+ :@else=>{},
1472
+ :@line=>1}},
1473
+ :@line=>1,
1474
+ :@arguments=>
1475
+ {:iterarguments=>
1476
+ {:@block=>nil,
1477
+ :@arity=>-1,
1478
+ :@prelude=>nil,
1479
+ :@optional=>0,
1480
+ :@splat=>nil,
1481
+ :@line=>1,
1482
+ :@splat_index=>-2,
1483
+ :@required_args=>0}}}},
1484
+ :@name=>:m,
1485
+ :@line=>1,
1486
+ :@privately=>true,
1487
+ :@receiver=>{:self=>{:@line=>1}},
1488
+ :@check_for_local=>false}}
1489
+
1490
+ ruby.should parse_as(ast)
1491
+ end
1492
+
1493
+ it 'should correctly parse "m { next x }"' do
1494
+ ruby = 'm { next x }'
1495
+ ast = {:send=>
1496
+ {:@block=>
1497
+ {:iter=>
1498
+ {:@body=>
1499
+ {:next=>
1500
+ {:@line=>1,
1501
+ :@value=>
1502
+ {:send=>
1503
+ {:@block=>nil,
1504
+ :@name=>:x,
1505
+ :@line=>1,
1506
+ :@privately=>true,
1507
+ :@receiver=>{:self=>{:@line=>1}},
1508
+ :@check_for_local=>false}}}},
1509
+ :@line=>1,
1510
+ :@arguments=>
1511
+ {:iterarguments=>
1512
+ {:@block=>nil,
1513
+ :@arity=>-1,
1514
+ :@prelude=>nil,
1515
+ :@optional=>0,
1516
+ :@splat=>nil,
1517
+ :@line=>1,
1518
+ :@splat_index=>-2,
1519
+ :@required_args=>0}}}},
1520
+ :@name=>:m,
1521
+ :@line=>1,
1522
+ :@privately=>true,
1523
+ :@receiver=>{:self=>{:@line=>1}},
1524
+ :@check_for_local=>false}}
1525
+
1526
+ ruby.should parse_as(ast)
1527
+ end
1528
+
1529
+ it 'should correctly parse "m { x = 1; next x }"' do
1530
+ ruby = 'm { x = 1; next x }'
1531
+ ast = {:send=>
1532
+ {:@block=>
1533
+ {:iter=>
1534
+ {:@body=>
1535
+ {:block=>
1536
+ {:@array=>
1537
+ [{:localvariableassignment=>
1538
+ {:@variable=>nil,
1539
+ :@name=>:x,
1540
+ :@line=>1,
1541
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
1542
+ {:next=>
1543
+ {:@line=>1,
1544
+ :@value=>
1545
+ {:localvariableaccess=>
1546
+ {:@variable=>nil, :@name=>:x, :@line=>1}}}}],
1547
+ :@line=>1}},
1548
+ :@line=>1,
1549
+ :@arguments=>
1550
+ {:iterarguments=>
1551
+ {:@block=>nil,
1552
+ :@arity=>-1,
1553
+ :@prelude=>nil,
1554
+ :@optional=>0,
1555
+ :@splat=>nil,
1556
+ :@line=>1,
1557
+ :@splat_index=>-2,
1558
+ :@required_args=>0}}}},
1559
+ :@name=>:m,
1560
+ :@line=>1,
1561
+ :@privately=>true,
1562
+ :@receiver=>{:self=>{:@line=>1}},
1563
+ :@check_for_local=>false}}
1564
+
1565
+ ruby.should parse_as(ast)
1566
+ end
1567
+
1568
+ it 'should correctly parse "m { next [1] }"' do
1569
+ ruby = 'm { next [1] }'
1570
+ ast = {:send=>
1571
+ {:@block=>
1572
+ {:iter=>
1573
+ {:@body=>
1574
+ {:next=>
1575
+ {:@line=>1,
1576
+ :@value=>
1577
+ {:arrayliteral=>
1578
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1579
+ :@line=>1}}}},
1580
+ :@line=>1,
1581
+ :@arguments=>
1582
+ {:iterarguments=>
1583
+ {:@block=>nil,
1584
+ :@arity=>-1,
1585
+ :@prelude=>nil,
1586
+ :@optional=>0,
1587
+ :@splat=>nil,
1588
+ :@line=>1,
1589
+ :@splat_index=>-2,
1590
+ :@required_args=>0}}}},
1591
+ :@name=>:m,
1592
+ :@line=>1,
1593
+ :@privately=>true,
1594
+ :@receiver=>{:self=>{:@line=>1}},
1595
+ :@check_for_local=>false}}
1596
+
1597
+ ruby.should parse_as(ast)
1598
+ end
1599
+
1600
+ it 'should correctly parse "m { next *[1] }"' do
1601
+ ruby = 'm { next *[1] }'
1602
+ ast = {:send=>
1603
+ {:@block=>
1604
+ {:iter=>
1605
+ {:@body=>
1606
+ {:next=>
1607
+ {:@line=>1,
1608
+ :@value=>
1609
+ {:svalue=>
1610
+ {:@line=>1,
1611
+ :@value=>
1612
+ {:splatvalue=>
1613
+ {:@line=>1,
1614
+ :@value=>
1615
+ {:arrayliteral=>
1616
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1617
+ :@line=>1}}}}}}}},
1618
+ :@line=>1,
1619
+ :@arguments=>
1620
+ {:iterarguments=>
1621
+ {:@block=>nil,
1622
+ :@arity=>-1,
1623
+ :@prelude=>nil,
1624
+ :@optional=>0,
1625
+ :@splat=>nil,
1626
+ :@line=>1,
1627
+ :@splat_index=>-2,
1628
+ :@required_args=>0}}}},
1629
+ :@name=>:m,
1630
+ :@line=>1,
1631
+ :@privately=>true,
1632
+ :@receiver=>{:self=>{:@line=>1}},
1633
+ :@check_for_local=>false}}
1634
+
1635
+ ruby.should parse_as(ast)
1636
+ end
1637
+
1638
+ it 'should correctly parse "m { next [*[1]] }"' do
1639
+ ruby = 'm { next [*[1]] }'
1640
+ ast = {:send=>
1641
+ {:@block=>
1642
+ {:iter=>
1643
+ {:@body=>
1644
+ {:next=>
1645
+ {:@line=>1,
1646
+ :@value=>
1647
+ {:splatvalue=>
1648
+ {:@line=>1,
1649
+ :@value=>
1650
+ {:arrayliteral=>
1651
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1652
+ :@line=>1}}}}}},
1653
+ :@line=>1,
1654
+ :@arguments=>
1655
+ {:iterarguments=>
1656
+ {:@block=>nil,
1657
+ :@arity=>-1,
1658
+ :@prelude=>nil,
1659
+ :@optional=>0,
1660
+ :@splat=>nil,
1661
+ :@line=>1,
1662
+ :@splat_index=>-2,
1663
+ :@required_args=>0}}}},
1664
+ :@name=>:m,
1665
+ :@line=>1,
1666
+ :@privately=>true,
1667
+ :@receiver=>{:self=>{:@line=>1}},
1668
+ :@check_for_local=>false}}
1669
+
1670
+ ruby.should parse_as(ast)
1671
+ end
1672
+
1673
+ it 'should correctly parse "m { next *[1, 2] }"' do
1674
+ ruby = 'm { next *[1, 2] }'
1675
+ ast = {:send=>
1676
+ {:@block=>
1677
+ {:iter=>
1678
+ {:@body=>
1679
+ {:next=>
1680
+ {:@line=>1,
1681
+ :@value=>
1682
+ {:svalue=>
1683
+ {:@line=>1,
1684
+ :@value=>
1685
+ {:splatvalue=>
1686
+ {:@line=>1,
1687
+ :@value=>
1688
+ {:arrayliteral=>
1689
+ {:@body=>
1690
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1691
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
1692
+ :@line=>1}}}}}}}},
1693
+ :@line=>1,
1694
+ :@arguments=>
1695
+ {:iterarguments=>
1696
+ {:@block=>nil,
1697
+ :@arity=>-1,
1698
+ :@prelude=>nil,
1699
+ :@optional=>0,
1700
+ :@splat=>nil,
1701
+ :@line=>1,
1702
+ :@splat_index=>-2,
1703
+ :@required_args=>0}}}},
1704
+ :@name=>:m,
1705
+ :@line=>1,
1706
+ :@privately=>true,
1707
+ :@receiver=>{:self=>{:@line=>1}},
1708
+ :@check_for_local=>false}}
1709
+
1710
+ ruby.should parse_as(ast)
1711
+ end
1712
+
1713
+ it 'should correctly parse "m { next [*[1, 2]] }"' do
1714
+ ruby = 'm { next [*[1, 2]] }'
1715
+ ast = {:send=>
1716
+ {:@block=>
1717
+ {:iter=>
1718
+ {:@body=>
1719
+ {:next=>
1720
+ {:@line=>1,
1721
+ :@value=>
1722
+ {:splatvalue=>
1723
+ {:@line=>1,
1724
+ :@value=>
1725
+ {:arrayliteral=>
1726
+ {:@body=>
1727
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1728
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
1729
+ :@line=>1}}}}}},
1730
+ :@line=>1,
1731
+ :@arguments=>
1732
+ {:iterarguments=>
1733
+ {:@block=>nil,
1734
+ :@arity=>-1,
1735
+ :@prelude=>nil,
1736
+ :@optional=>0,
1737
+ :@splat=>nil,
1738
+ :@line=>1,
1739
+ :@splat_index=>-2,
1740
+ :@required_args=>0}}}},
1741
+ :@name=>:m,
1742
+ :@line=>1,
1743
+ :@privately=>true,
1744
+ :@receiver=>{:self=>{:@line=>1}},
1745
+ :@check_for_local=>false}}
1746
+
1747
+ ruby.should parse_as(ast)
1748
+ end
1749
+
1750
+ it 'should correctly parse "m { break }"' do
1751
+ ruby = 'm { break }'
1752
+ ast = {:send=>
1753
+ {:@block=>
1754
+ {:iter=>
1755
+ {:@body=>{:break=>{:@line=>1, :@value=>{}}},
1756
+ :@line=>1,
1757
+ :@arguments=>
1758
+ {:iterarguments=>
1759
+ {:@block=>nil,
1760
+ :@arity=>-1,
1761
+ :@prelude=>nil,
1762
+ :@optional=>0,
1763
+ :@splat=>nil,
1764
+ :@line=>1,
1765
+ :@splat_index=>-2,
1766
+ :@required_args=>0}}}},
1767
+ :@name=>:m,
1768
+ :@line=>1,
1769
+ :@privately=>true,
1770
+ :@receiver=>{:self=>{:@line=>1}},
1771
+ :@check_for_local=>false}}
1772
+
1773
+ ruby.should parse_as(ast)
1774
+ end
1775
+
1776
+ it 'should correctly parse "m { break if x }"' do
1777
+ ruby = 'm { break if x }'
1778
+ ast = {:send=>
1779
+ {:@block=>
1780
+ {:iter=>
1781
+ {:@body=>
1782
+ {:if=>
1783
+ {:@body=>{:break=>{:@line=>1, :@value=>{}}},
1784
+ :@condition=>
1785
+ {:send=>
1786
+ {:@block=>nil,
1787
+ :@name=>:x,
1788
+ :@line=>1,
1789
+ :@privately=>true,
1790
+ :@receiver=>{:self=>{:@line=>1}},
1791
+ :@check_for_local=>false}},
1792
+ :@else=>{},
1793
+ :@line=>1}},
1794
+ :@line=>1,
1795
+ :@arguments=>
1796
+ {:iterarguments=>
1797
+ {:@block=>nil,
1798
+ :@arity=>-1,
1799
+ :@prelude=>nil,
1800
+ :@optional=>0,
1801
+ :@splat=>nil,
1802
+ :@line=>1,
1803
+ :@splat_index=>-2,
1804
+ :@required_args=>0}}}},
1805
+ :@name=>:m,
1806
+ :@line=>1,
1807
+ :@privately=>true,
1808
+ :@receiver=>{:self=>{:@line=>1}},
1809
+ :@check_for_local=>false}}
1810
+
1811
+ ruby.should parse_as(ast)
1812
+ end
1813
+
1814
+ it 'should correctly parse "m { break x }"' do
1815
+ ruby = 'm { break x }'
1816
+ ast = {:send=>
1817
+ {:@block=>
1818
+ {:iter=>
1819
+ {:@body=>
1820
+ {:break=>
1821
+ {:@line=>1,
1822
+ :@value=>
1823
+ {:send=>
1824
+ {:@block=>nil,
1825
+ :@name=>:x,
1826
+ :@line=>1,
1827
+ :@privately=>true,
1828
+ :@receiver=>{:self=>{:@line=>1}},
1829
+ :@check_for_local=>false}}}},
1830
+ :@line=>1,
1831
+ :@arguments=>
1832
+ {:iterarguments=>
1833
+ {:@block=>nil,
1834
+ :@arity=>-1,
1835
+ :@prelude=>nil,
1836
+ :@optional=>0,
1837
+ :@splat=>nil,
1838
+ :@line=>1,
1839
+ :@splat_index=>-2,
1840
+ :@required_args=>0}}}},
1841
+ :@name=>:m,
1842
+ :@line=>1,
1843
+ :@privately=>true,
1844
+ :@receiver=>{:self=>{:@line=>1}},
1845
+ :@check_for_local=>false}}
1846
+
1847
+ ruby.should parse_as(ast)
1848
+ end
1849
+
1850
+ it 'should correctly parse "m { x = 1; break x }"' do
1851
+ ruby = 'm { x = 1; break x }'
1852
+ ast = {:send=>
1853
+ {:@block=>
1854
+ {:iter=>
1855
+ {:@body=>
1856
+ {:block=>
1857
+ {:@array=>
1858
+ [{:localvariableassignment=>
1859
+ {:@variable=>nil,
1860
+ :@name=>:x,
1861
+ :@line=>1,
1862
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
1863
+ {:break=>
1864
+ {:@line=>1,
1865
+ :@value=>
1866
+ {:localvariableaccess=>
1867
+ {:@variable=>nil, :@name=>:x, :@line=>1}}}}],
1868
+ :@line=>1}},
1869
+ :@line=>1,
1870
+ :@arguments=>
1871
+ {:iterarguments=>
1872
+ {:@block=>nil,
1873
+ :@arity=>-1,
1874
+ :@prelude=>nil,
1875
+ :@optional=>0,
1876
+ :@splat=>nil,
1877
+ :@line=>1,
1878
+ :@splat_index=>-2,
1879
+ :@required_args=>0}}}},
1880
+ :@name=>:m,
1881
+ :@line=>1,
1882
+ :@privately=>true,
1883
+ :@receiver=>{:self=>{:@line=>1}},
1884
+ :@check_for_local=>false}}
1885
+
1886
+ ruby.should parse_as(ast)
1887
+ end
1888
+
1889
+ it 'should correctly parse "m { break [1] }"' do
1890
+ ruby = 'm { break [1] }'
1891
+ ast = {:send=>
1892
+ {:@block=>
1893
+ {:iter=>
1894
+ {:@body=>
1895
+ {:break=>
1896
+ {:@line=>1,
1897
+ :@value=>
1898
+ {:arrayliteral=>
1899
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1900
+ :@line=>1}}}},
1901
+ :@line=>1,
1902
+ :@arguments=>
1903
+ {:iterarguments=>
1904
+ {:@block=>nil,
1905
+ :@arity=>-1,
1906
+ :@prelude=>nil,
1907
+ :@optional=>0,
1908
+ :@splat=>nil,
1909
+ :@line=>1,
1910
+ :@splat_index=>-2,
1911
+ :@required_args=>0}}}},
1912
+ :@name=>:m,
1913
+ :@line=>1,
1914
+ :@privately=>true,
1915
+ :@receiver=>{:self=>{:@line=>1}},
1916
+ :@check_for_local=>false}}
1917
+
1918
+ ruby.should parse_as(ast)
1919
+ end
1920
+
1921
+ it 'should correctly parse "m { break *[1] }"' do
1922
+ ruby = 'm { break *[1] }'
1923
+ ast = {:send=>
1924
+ {:@block=>
1925
+ {:iter=>
1926
+ {:@body=>
1927
+ {:break=>
1928
+ {:@line=>1,
1929
+ :@value=>
1930
+ {:svalue=>
1931
+ {:@line=>1,
1932
+ :@value=>
1933
+ {:splatvalue=>
1934
+ {:@line=>1,
1935
+ :@value=>
1936
+ {:arrayliteral=>
1937
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1938
+ :@line=>1}}}}}}}},
1939
+ :@line=>1,
1940
+ :@arguments=>
1941
+ {:iterarguments=>
1942
+ {:@block=>nil,
1943
+ :@arity=>-1,
1944
+ :@prelude=>nil,
1945
+ :@optional=>0,
1946
+ :@splat=>nil,
1947
+ :@line=>1,
1948
+ :@splat_index=>-2,
1949
+ :@required_args=>0}}}},
1950
+ :@name=>:m,
1951
+ :@line=>1,
1952
+ :@privately=>true,
1953
+ :@receiver=>{:self=>{:@line=>1}},
1954
+ :@check_for_local=>false}}
1955
+
1956
+ ruby.should parse_as(ast)
1957
+ end
1958
+
1959
+ it 'should correctly parse "m { break [*[1]] }"' do
1960
+ ruby = 'm { break [*[1]] }'
1961
+ ast = {:send=>
1962
+ {:@block=>
1963
+ {:iter=>
1964
+ {:@body=>
1965
+ {:break=>
1966
+ {:@line=>1,
1967
+ :@value=>
1968
+ {:splatvalue=>
1969
+ {:@line=>1,
1970
+ :@value=>
1971
+ {:arrayliteral=>
1972
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1973
+ :@line=>1}}}}}},
1974
+ :@line=>1,
1975
+ :@arguments=>
1976
+ {:iterarguments=>
1977
+ {:@block=>nil,
1978
+ :@arity=>-1,
1979
+ :@prelude=>nil,
1980
+ :@optional=>0,
1981
+ :@splat=>nil,
1982
+ :@line=>1,
1983
+ :@splat_index=>-2,
1984
+ :@required_args=>0}}}},
1985
+ :@name=>:m,
1986
+ :@line=>1,
1987
+ :@privately=>true,
1988
+ :@receiver=>{:self=>{:@line=>1}},
1989
+ :@check_for_local=>false}}
1990
+
1991
+ ruby.should parse_as(ast)
1992
+ end
1993
+
1994
+ it 'should correctly parse "m { break *[1, 2] }"' do
1995
+ ruby = 'm { break *[1, 2] }'
1996
+ ast = {:send=>
1997
+ {:@block=>
1998
+ {:iter=>
1999
+ {:@body=>
2000
+ {:break=>
2001
+ {:@line=>1,
2002
+ :@value=>
2003
+ {:svalue=>
2004
+ {:@line=>1,
2005
+ :@value=>
2006
+ {:splatvalue=>
2007
+ {:@line=>1,
2008
+ :@value=>
2009
+ {:arrayliteral=>
2010
+ {:@body=>
2011
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
2012
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
2013
+ :@line=>1}}}}}}}},
2014
+ :@line=>1,
2015
+ :@arguments=>
2016
+ {:iterarguments=>
2017
+ {:@block=>nil,
2018
+ :@arity=>-1,
2019
+ :@prelude=>nil,
2020
+ :@optional=>0,
2021
+ :@splat=>nil,
2022
+ :@line=>1,
2023
+ :@splat_index=>-2,
2024
+ :@required_args=>0}}}},
2025
+ :@name=>:m,
2026
+ :@line=>1,
2027
+ :@privately=>true,
2028
+ :@receiver=>{:self=>{:@line=>1}},
2029
+ :@check_for_local=>false}}
2030
+
2031
+ ruby.should parse_as(ast)
2032
+ end
2033
+
2034
+ it 'should correctly parse "m { break [*[1, 2]] }"' do
2035
+ ruby = 'm { break [*[1, 2]] }'
2036
+ ast = {:send=>
2037
+ {:@block=>
2038
+ {:iter=>
2039
+ {:@body=>
2040
+ {:break=>
2041
+ {:@line=>1,
2042
+ :@value=>
2043
+ {:splatvalue=>
2044
+ {:@line=>1,
2045
+ :@value=>
2046
+ {:arrayliteral=>
2047
+ {:@body=>
2048
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
2049
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
2050
+ :@line=>1}}}}}},
2051
+ :@line=>1,
2052
+ :@arguments=>
2053
+ {:iterarguments=>
2054
+ {:@block=>nil,
2055
+ :@arity=>-1,
2056
+ :@prelude=>nil,
2057
+ :@optional=>0,
2058
+ :@splat=>nil,
2059
+ :@line=>1,
2060
+ :@splat_index=>-2,
2061
+ :@required_args=>0}}}},
2062
+ :@name=>:m,
2063
+ :@line=>1,
2064
+ :@privately=>true,
2065
+ :@receiver=>{:self=>{:@line=>1}},
2066
+ :@check_for_local=>false}}
2067
+
2068
+ ruby.should parse_as(ast)
2069
+ end
2070
+
2071
+ it 'should correctly parse "m { return }"' do
2072
+ ruby = 'm { return }'
2073
+ ast = {:send=>
2074
+ {:@block=>
2075
+ {:iter=>
2076
+ {:@body=>{:return=>{:@splat=>nil, :@line=>1, :@value=>nil}},
2077
+ :@line=>1,
2078
+ :@arguments=>
2079
+ {:iterarguments=>
2080
+ {:@block=>nil,
2081
+ :@arity=>-1,
2082
+ :@prelude=>nil,
2083
+ :@optional=>0,
2084
+ :@splat=>nil,
2085
+ :@line=>1,
2086
+ :@splat_index=>-2,
2087
+ :@required_args=>0}}}},
2088
+ :@name=>:m,
2089
+ :@line=>1,
2090
+ :@privately=>true,
2091
+ :@receiver=>{:self=>{:@line=>1}},
2092
+ :@check_for_local=>false}}
2093
+
2094
+ ruby.should parse_as(ast)
2095
+ end
2096
+
2097
+ it 'should correctly parse "m { return if x }"' do
2098
+ ruby = 'm { return if x }'
2099
+ ast = {:send=>
2100
+ {:@block=>
2101
+ {:iter=>
2102
+ {:@body=>
2103
+ {:if=>
2104
+ {:@body=>{:return=>{:@splat=>nil, :@line=>1, :@value=>nil}},
2105
+ :@condition=>
2106
+ {:send=>
2107
+ {:@block=>nil,
2108
+ :@name=>:x,
2109
+ :@line=>1,
2110
+ :@privately=>true,
2111
+ :@receiver=>{:self=>{:@line=>1}},
2112
+ :@check_for_local=>false}},
2113
+ :@else=>{},
2114
+ :@line=>1}},
2115
+ :@line=>1,
2116
+ :@arguments=>
2117
+ {:iterarguments=>
2118
+ {:@block=>nil,
2119
+ :@arity=>-1,
2120
+ :@prelude=>nil,
2121
+ :@optional=>0,
2122
+ :@splat=>nil,
2123
+ :@line=>1,
2124
+ :@splat_index=>-2,
2125
+ :@required_args=>0}}}},
2126
+ :@name=>:m,
2127
+ :@line=>1,
2128
+ :@privately=>true,
2129
+ :@receiver=>{:self=>{:@line=>1}},
2130
+ :@check_for_local=>false}}
2131
+
2132
+ ruby.should parse_as(ast)
2133
+ end
2134
+
2135
+ it 'should correctly parse "m { return x }"' do
2136
+ ruby = 'm { return x }'
2137
+ ast = {:send=>
2138
+ {:@block=>
2139
+ {:iter=>
2140
+ {:@body=>
2141
+ {:return=>
2142
+ {:@splat=>nil,
2143
+ :@line=>1,
2144
+ :@value=>
2145
+ {:send=>
2146
+ {:@block=>nil,
2147
+ :@name=>:x,
2148
+ :@line=>1,
2149
+ :@privately=>true,
2150
+ :@receiver=>{:self=>{:@line=>1}},
2151
+ :@check_for_local=>false}}}},
2152
+ :@line=>1,
2153
+ :@arguments=>
2154
+ {:iterarguments=>
2155
+ {:@block=>nil,
2156
+ :@arity=>-1,
2157
+ :@prelude=>nil,
2158
+ :@optional=>0,
2159
+ :@splat=>nil,
2160
+ :@line=>1,
2161
+ :@splat_index=>-2,
2162
+ :@required_args=>0}}}},
2163
+ :@name=>:m,
2164
+ :@line=>1,
2165
+ :@privately=>true,
2166
+ :@receiver=>{:self=>{:@line=>1}},
2167
+ :@check_for_local=>false}}
2168
+
2169
+ ruby.should parse_as(ast)
2170
+ end
2171
+
2172
+ it 'should correctly parse "m { x = 1; return x }"' do
2173
+ ruby = 'm { x = 1; return x }'
2174
+ ast = {:send=>
2175
+ {:@block=>
2176
+ {:iter=>
2177
+ {:@body=>
2178
+ {:block=>
2179
+ {:@array=>
2180
+ [{:localvariableassignment=>
2181
+ {:@variable=>nil,
2182
+ :@name=>:x,
2183
+ :@line=>1,
2184
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
2185
+ {:return=>
2186
+ {:@splat=>nil,
2187
+ :@line=>1,
2188
+ :@value=>
2189
+ {:localvariableaccess=>
2190
+ {:@variable=>nil, :@name=>:x, :@line=>1}}}}],
2191
+ :@line=>1}},
2192
+ :@line=>1,
2193
+ :@arguments=>
2194
+ {:iterarguments=>
2195
+ {:@block=>nil,
2196
+ :@arity=>-1,
2197
+ :@prelude=>nil,
2198
+ :@optional=>0,
2199
+ :@splat=>nil,
2200
+ :@line=>1,
2201
+ :@splat_index=>-2,
2202
+ :@required_args=>0}}}},
2203
+ :@name=>:m,
2204
+ :@line=>1,
2205
+ :@privately=>true,
2206
+ :@receiver=>{:self=>{:@line=>1}},
2207
+ :@check_for_local=>false}}
2208
+
2209
+ ruby.should parse_as(ast)
2210
+ end
2211
+
2212
+ it 'should correctly parse "m { return [1] }"' do
2213
+ ruby = 'm { return [1] }'
2214
+ ast = {:send=>
2215
+ {:@block=>
2216
+ {:iter=>
2217
+ {:@body=>
2218
+ {:return=>
2219
+ {:@splat=>nil,
2220
+ :@line=>1,
2221
+ :@value=>
2222
+ {:arrayliteral=>
2223
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
2224
+ :@line=>1}}}},
2225
+ :@line=>1,
2226
+ :@arguments=>
2227
+ {:iterarguments=>
2228
+ {:@block=>nil,
2229
+ :@arity=>-1,
2230
+ :@prelude=>nil,
2231
+ :@optional=>0,
2232
+ :@splat=>nil,
2233
+ :@line=>1,
2234
+ :@splat_index=>-2,
2235
+ :@required_args=>0}}}},
2236
+ :@name=>:m,
2237
+ :@line=>1,
2238
+ :@privately=>true,
2239
+ :@receiver=>{:self=>{:@line=>1}},
2240
+ :@check_for_local=>false}}
2241
+
2242
+ ruby.should parse_as(ast)
2243
+ end
2244
+
2245
+ it 'should correctly parse "m { return *[1] }"' do
2246
+ ruby = 'm { return *[1] }'
2247
+ ast = {:send=>
2248
+ {:@block=>
2249
+ {:iter=>
2250
+ {:@body=>
2251
+ {:return=>
2252
+ {:@splat=>nil,
2253
+ :@line=>1,
2254
+ :@value=>
2255
+ {:svalue=>
2256
+ {:@line=>1,
2257
+ :@value=>
2258
+ {:splatvalue=>
2259
+ {:@line=>1,
2260
+ :@value=>
2261
+ {:arrayliteral=>
2262
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
2263
+ :@line=>1}}}}}}}},
2264
+ :@line=>1,
2265
+ :@arguments=>
2266
+ {:iterarguments=>
2267
+ {:@block=>nil,
2268
+ :@arity=>-1,
2269
+ :@prelude=>nil,
2270
+ :@optional=>0,
2271
+ :@splat=>nil,
2272
+ :@line=>1,
2273
+ :@splat_index=>-2,
2274
+ :@required_args=>0}}}},
2275
+ :@name=>:m,
2276
+ :@line=>1,
2277
+ :@privately=>true,
2278
+ :@receiver=>{:self=>{:@line=>1}},
2279
+ :@check_for_local=>false}}
2280
+
2281
+ ruby.should parse_as(ast)
2282
+ end
2283
+
2284
+ it 'should correctly parse "m { return *[1, 2] }"' do
2285
+ ruby = 'm { return *[1, 2] }'
2286
+ ast = {:send=>
2287
+ {:@block=>
2288
+ {:iter=>
2289
+ {:@body=>
2290
+ {:return=>
2291
+ {:@splat=>nil,
2292
+ :@line=>1,
2293
+ :@value=>
2294
+ {:svalue=>
2295
+ {:@line=>1,
2296
+ :@value=>
2297
+ {:splatvalue=>
2298
+ {:@line=>1,
2299
+ :@value=>
2300
+ {:arrayliteral=>
2301
+ {:@body=>
2302
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
2303
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
2304
+ :@line=>1}}}}}}}},
2305
+ :@line=>1,
2306
+ :@arguments=>
2307
+ {:iterarguments=>
2308
+ {:@block=>nil,
2309
+ :@arity=>-1,
2310
+ :@prelude=>nil,
2311
+ :@optional=>0,
2312
+ :@splat=>nil,
2313
+ :@line=>1,
2314
+ :@splat_index=>-2,
2315
+ :@required_args=>0}}}},
2316
+ :@name=>:m,
2317
+ :@line=>1,
2318
+ :@privately=>true,
2319
+ :@receiver=>{:self=>{:@line=>1}},
2320
+ :@check_for_local=>false}}
2321
+
2322
+ ruby.should parse_as(ast)
2323
+ end
2324
+
2325
+ it 'should correctly parse "m { return [*[1, 2]] }"' do
2326
+ ruby = 'm { return [*[1, 2]] }'
2327
+ ast = {:send=>
2328
+ {:@block=>
2329
+ {:iter=>
2330
+ {:@body=>
2331
+ {:return=>
2332
+ {:@splat=>nil,
2333
+ :@line=>1,
2334
+ :@value=>
2335
+ {:splatvalue=>
2336
+ {:@line=>1,
2337
+ :@value=>
2338
+ {:arrayliteral=>
2339
+ {:@body=>
2340
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
2341
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
2342
+ :@line=>1}}}}}},
2343
+ :@line=>1,
2344
+ :@arguments=>
2345
+ {:iterarguments=>
2346
+ {:@block=>nil,
2347
+ :@arity=>-1,
2348
+ :@prelude=>nil,
2349
+ :@optional=>0,
2350
+ :@splat=>nil,
2351
+ :@line=>1,
2352
+ :@splat_index=>-2,
2353
+ :@required_args=>0}}}},
2354
+ :@name=>:m,
2355
+ :@line=>1,
2356
+ :@privately=>true,
2357
+ :@receiver=>{:self=>{:@line=>1}},
2358
+ :@check_for_local=>false}}
2359
+
2360
+ ruby.should parse_as(ast)
2361
+ end
2362
+
2363
+ it 'should correctly parse "m { redo }"' do
2364
+ ruby = 'm { redo }'
2365
+ ast = {:send=>
2366
+ {:@block=>
2367
+ {:iter=>
2368
+ {:@body=>{:redo=>{:@line=>1}},
2369
+ :@line=>1,
2370
+ :@arguments=>
2371
+ {:iterarguments=>
2372
+ {:@block=>nil,
2373
+ :@arity=>-1,
2374
+ :@prelude=>nil,
2375
+ :@optional=>0,
2376
+ :@splat=>nil,
2377
+ :@line=>1,
2378
+ :@splat_index=>-2,
2379
+ :@required_args=>0}}}},
2380
+ :@name=>:m,
2381
+ :@line=>1,
2382
+ :@privately=>true,
2383
+ :@receiver=>{:self=>{:@line=>1}},
2384
+ :@check_for_local=>false}}
2385
+
2386
+ ruby.should parse_as(ast)
2387
+ end
2388
+
2389
+ it 'should correctly parse "m { redo if x }"' do
2390
+ ruby = 'm { redo if x }'
2391
+ ast = {:send=>
2392
+ {:@block=>
2393
+ {:iter=>
2394
+ {:@body=>
2395
+ {:if=>
2396
+ {:@body=>{:redo=>{:@line=>1}},
2397
+ :@condition=>
2398
+ {:send=>
2399
+ {:@block=>nil,
2400
+ :@name=>:x,
2401
+ :@line=>1,
2402
+ :@privately=>true,
2403
+ :@receiver=>{:self=>{:@line=>1}},
2404
+ :@check_for_local=>false}},
2405
+ :@else=>{},
2406
+ :@line=>1}},
2407
+ :@line=>1,
2408
+ :@arguments=>
2409
+ {:iterarguments=>
2410
+ {:@block=>nil,
2411
+ :@arity=>-1,
2412
+ :@prelude=>nil,
2413
+ :@optional=>0,
2414
+ :@splat=>nil,
2415
+ :@line=>1,
2416
+ :@splat_index=>-2,
2417
+ :@required_args=>0}}}},
2418
+ :@name=>:m,
2419
+ :@line=>1,
2420
+ :@privately=>true,
2421
+ :@receiver=>{:self=>{:@line=>1}},
2422
+ :@check_for_local=>false}}
2423
+
2424
+ ruby.should parse_as(ast)
2425
+ end
2426
+
2427
+ it 'should correctly parse "m(a) { retry }"' do
2428
+ ruby = 'm(a) { retry }'
2429
+ ast = {:sendwitharguments=>
2430
+ {:@block=>
2431
+ {:iter=>
2432
+ {:@body=>{:retry=>{:@line=>1}},
2433
+ :@line=>1,
2434
+ :@arguments=>
2435
+ {:iterarguments=>
2436
+ {:@block=>nil,
2437
+ :@arity=>-1,
2438
+ :@prelude=>nil,
2439
+ :@optional=>0,
2440
+ :@splat=>nil,
2441
+ :@line=>1,
2442
+ :@splat_index=>-2,
2443
+ :@required_args=>0}}}},
2444
+ :@name=>:m,
2445
+ :@line=>1,
2446
+ :@privately=>true,
2447
+ :@receiver=>{:self=>{:@line=>1}},
2448
+ :@check_for_local=>false,
2449
+ :@arguments=>
2450
+ {:actualarguments=>
2451
+ {:@array=>
2452
+ [{:send=>
2453
+ {:@block=>nil,
2454
+ :@name=>:a,
2455
+ :@line=>1,
2456
+ :@privately=>true,
2457
+ :@receiver=>{:self=>{:@line=>1}},
2458
+ :@check_for_local=>false}}],
2459
+ :@splat=>nil,
2460
+ :@line=>1}}}}
2461
+
2462
+ ruby.should parse_as(ast)
2463
+ end
2464
+
2465
+ it 'should correctly parse "m(a) { retry if x }"' do
2466
+ ruby = 'm(a) { retry if x }'
2467
+ ast = {:sendwitharguments=>
2468
+ {:@block=>
2469
+ {:iter=>
2470
+ {:@body=>
2471
+ {:if=>
2472
+ {:@body=>{:retry=>{:@line=>1}},
2473
+ :@condition=>
2474
+ {:send=>
2475
+ {:@block=>nil,
2476
+ :@name=>:x,
2477
+ :@line=>1,
2478
+ :@privately=>true,
2479
+ :@receiver=>{:self=>{:@line=>1}},
2480
+ :@check_for_local=>false}},
2481
+ :@else=>{},
2482
+ :@line=>1}},
2483
+ :@line=>1,
2484
+ :@arguments=>
2485
+ {:iterarguments=>
2486
+ {:@block=>nil,
2487
+ :@arity=>-1,
2488
+ :@prelude=>nil,
2489
+ :@optional=>0,
2490
+ :@splat=>nil,
2491
+ :@line=>1,
2492
+ :@splat_index=>-2,
2493
+ :@required_args=>0}}}},
2494
+ :@name=>:m,
2495
+ :@line=>1,
2496
+ :@privately=>true,
2497
+ :@receiver=>{:self=>{:@line=>1}},
2498
+ :@check_for_local=>false,
2499
+ :@arguments=>
2500
+ {:actualarguments=>
2501
+ {:@array=>
2502
+ [{:send=>
2503
+ {:@block=>nil,
2504
+ :@name=>:a,
2505
+ :@line=>1,
2506
+ :@privately=>true,
2507
+ :@receiver=>{:self=>{:@line=>1}},
2508
+ :@check_for_local=>false}}],
2509
+ :@splat=>nil,
2510
+ :@line=>1}}}}
2511
+
2512
+ ruby.should parse_as(ast)
2513
+ end
2514
+
2515
+ it 'should correctly parse "redo"' do
2516
+ ruby = 'redo'
2517
+ ast = {:redo=>{:@line=>1}}
2518
+
2519
+ ruby.should parse_as(ast)
2520
+ end
2521
+
2522
+ it 'should correctly parse "retry"' do
2523
+ ruby = 'retry'
2524
+ ast = {:retry=>{:@line=>1}}
2525
+
2526
+ ruby.should parse_as(ast)
2527
+ end
2528
+
2529
+ it 'should correctly parse "next"' do
2530
+ ruby = 'next'
2531
+ ast = {:next=>{:@line=>1, :@value=>nil}}
2532
+
2533
+ ruby.should parse_as(ast)
2534
+ end
2535
+
2536
+ it 'should correctly parse "def x(a); bar { super } end"' do
2537
+ ruby = <<-ruby
2538
+ def x(a)
2539
+ bar { super }
2540
+ end
2541
+ ruby
2542
+ ast = {:define=>
2543
+ {:@body=>
2544
+ {:block=>
2545
+ {:@array=>
2546
+ [{:send=>
2547
+ {:@block=>
2548
+ {:iter=>
2549
+ {:@body=>{:zsuper=>{:@block=>nil, :@line=>2}},
2550
+ :@line=>2,
2551
+ :@arguments=>
2552
+ {:iterarguments=>
2553
+ {:@block=>nil,
2554
+ :@arity=>-1,
2555
+ :@prelude=>nil,
2556
+ :@optional=>0,
2557
+ :@splat=>nil,
2558
+ :@line=>2,
2559
+ :@splat_index=>-2,
2560
+ :@required_args=>0}}}},
2561
+ :@name=>:bar,
2562
+ :@line=>2,
2563
+ :@privately=>true,
2564
+ :@receiver=>{:self=>{:@line=>2}},
2565
+ :@check_for_local=>false}}],
2566
+ :@line=>1}},
2567
+ :@name=>:x,
2568
+ :@line=>1,
2569
+ :@arguments=>
2570
+ {:formalarguments=>
2571
+ {:@block_arg=>nil,
2572
+ :@names=>[:a],
2573
+ :@defaults=>nil,
2574
+ :@optional=>[],
2575
+ :@splat=>nil,
2576
+ :@line=>1,
2577
+ :@required=>[:a]}}}}
2578
+
2579
+ ruby.should parse_as(ast)
2580
+ end
2581
+
2582
+ end