melbourne 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,1970 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Melbourne::Parser do
4
+
5
+ it 'should correctly parse "a, b.c = b.c, true"' do
6
+ ruby = 'a, b.c = b.c, true'
7
+ ast = {:masgn=>
8
+ {:@block=>nil,
9
+ :@fixed=>true,
10
+ :@splat=>nil,
11
+ :@line=>1,
12
+ :@left=>
13
+ {:arrayliteral=>
14
+ {:@body=>
15
+ [{:localvariableassignment=>
16
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
17
+ {:attributeassignment=>
18
+ {:@name=>:c=,
19
+ :@line=>1,
20
+ :@privately=>false,
21
+ :@receiver=>
22
+ {:send=>
23
+ {:@block=>nil,
24
+ :@name=>:b,
25
+ :@line=>1,
26
+ :@privately=>true,
27
+ :@receiver=>{:self=>{:@line=>1}},
28
+ :@check_for_local=>false}},
29
+ :@arguments=>
30
+ {:actualarguments=>{:@array=>[], :@splat=>nil, :@line=>1}}}}],
31
+ :@line=>1}},
32
+ :@right=>
33
+ {:arrayliteral=>
34
+ {:@body=>
35
+ [{:send=>
36
+ {:@block=>nil,
37
+ :@name=>:c,
38
+ :@line=>1,
39
+ :@privately=>false,
40
+ :@receiver=>
41
+ {:send=>
42
+ {:@block=>nil,
43
+ :@name=>:b,
44
+ :@line=>1,
45
+ :@privately=>true,
46
+ :@receiver=>{:self=>{:@line=>1}},
47
+ :@check_for_local=>false}},
48
+ :@check_for_local=>false}},
49
+ {:true=>{:@line=>1}}],
50
+ :@line=>1}}}}
51
+
52
+ ruby.should parse_as(ast)
53
+ end
54
+
55
+ it 'should correctly parse "a, b = 1, 2, 3"' do
56
+ ruby = 'a, b = 1, 2, 3'
57
+ ast = {:masgn=>
58
+ {:@block=>nil,
59
+ :@fixed=>true,
60
+ :@splat=>nil,
61
+ :@line=>1,
62
+ :@left=>
63
+ {:arrayliteral=>
64
+ {:@body=>
65
+ [{:localvariableassignment=>
66
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
67
+ {:localvariableassignment=>
68
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
69
+ :@line=>1}},
70
+ :@right=>
71
+ {:arrayliteral=>
72
+ {:@body=>
73
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
74
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
75
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
76
+ :@line=>1}}}}
77
+
78
+ ruby.should parse_as(ast)
79
+ end
80
+
81
+ it 'should correctly parse "a, b = c, d"' do
82
+ ruby = 'a, b = c, d'
83
+ ast = {:masgn=>
84
+ {:@block=>nil,
85
+ :@fixed=>true,
86
+ :@splat=>nil,
87
+ :@line=>1,
88
+ :@left=>
89
+ {:arrayliteral=>
90
+ {:@body=>
91
+ [{:localvariableassignment=>
92
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
93
+ {:localvariableassignment=>
94
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
95
+ :@line=>1}},
96
+ :@right=>
97
+ {:arrayliteral=>
98
+ {:@body=>
99
+ [{:send=>
100
+ {:@block=>nil,
101
+ :@name=>:c,
102
+ :@line=>1,
103
+ :@privately=>true,
104
+ :@receiver=>{:self=>{:@line=>1}},
105
+ :@check_for_local=>false}},
106
+ {:send=>
107
+ {:@block=>nil,
108
+ :@name=>:d,
109
+ :@line=>1,
110
+ :@privately=>true,
111
+ :@receiver=>{:self=>{:@line=>1}},
112
+ :@check_for_local=>false}}],
113
+ :@line=>1}}}}
114
+
115
+ ruby.should parse_as(ast)
116
+ end
117
+
118
+ it 'should correctly parse "a, b, *c = 1, 2, *[3, 4]"' do
119
+ ruby = 'a, b, *c = 1, 2, *[3, 4]'
120
+ ast = {:masgn=>
121
+ {:@block=>nil,
122
+ :@fixed=>false,
123
+ :@splat=>
124
+ {:splatassignment=>
125
+ {:@line=>1,
126
+ :@value=>
127
+ {:localvariableassignment=>
128
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
129
+ :@line=>1,
130
+ :@left=>
131
+ {:arrayliteral=>
132
+ {:@body=>
133
+ [{:localvariableassignment=>
134
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
135
+ {:localvariableassignment=>
136
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
137
+ :@line=>1}},
138
+ :@right=>
139
+ {:concatargs=>
140
+ {:@array=>
141
+ {:arrayliteral=>
142
+ {:@body=>
143
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
144
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
145
+ :@line=>1}},
146
+ :@size=>2,
147
+ :@rest=>
148
+ {:arrayliteral=>
149
+ {:@body=>
150
+ [{:fixnumliteral=>{:@line=>1, :@value=>3}},
151
+ {:fixnumliteral=>{:@line=>1, :@value=>4}}],
152
+ :@line=>1}},
153
+ :@line=>1}}}}
154
+
155
+ ruby.should parse_as(ast)
156
+ end
157
+
158
+ it 'should correctly parse "a.b, a.c, _ = q"' do
159
+ ruby = 'a.b, a.c, _ = q'
160
+ ast = {:masgn=>
161
+ {:@block=>nil,
162
+ :@fixed=>false,
163
+ :@splat=>nil,
164
+ :@line=>1,
165
+ :@left=>
166
+ {:arrayliteral=>
167
+ {:@body=>
168
+ [{:attributeassignment=>
169
+ {:@name=>:b=,
170
+ :@line=>1,
171
+ :@privately=>false,
172
+ :@receiver=>
173
+ {:send=>
174
+ {:@block=>nil,
175
+ :@name=>:a,
176
+ :@line=>1,
177
+ :@privately=>true,
178
+ :@receiver=>{:self=>{:@line=>1}},
179
+ :@check_for_local=>false}},
180
+ :@arguments=>
181
+ {:actualarguments=>{:@array=>[], :@splat=>nil, :@line=>1}}}},
182
+ {:attributeassignment=>
183
+ {:@name=>:c=,
184
+ :@line=>1,
185
+ :@privately=>false,
186
+ :@receiver=>
187
+ {:send=>
188
+ {:@block=>nil,
189
+ :@name=>:a,
190
+ :@line=>1,
191
+ :@privately=>true,
192
+ :@receiver=>{:self=>{:@line=>1}},
193
+ :@check_for_local=>false}},
194
+ :@arguments=>
195
+ {:actualarguments=>{:@array=>[], :@splat=>nil, :@line=>1}}}},
196
+ {:localvariableassignment=>
197
+ {:@variable=>nil, :@name=>:_, :@line=>1, :@value=>nil}}],
198
+ :@line=>1}},
199
+ :@right=>
200
+ {:toarray=>
201
+ {:@line=>1,
202
+ :@value=>
203
+ {:send=>
204
+ {:@block=>nil,
205
+ :@name=>:q,
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 "a, i, j = [], 1, 2; a[i], a[j] = a[j], a[i]"' do
215
+ ruby = <<-ruby
216
+ a, i, j = [], 1, 2
217
+ a[i], a[j] = a[j], a[i]
218
+ ruby
219
+ ast = {:block=>
220
+ {:@array=>
221
+ [{:masgn=>
222
+ {:@block=>nil,
223
+ :@fixed=>true,
224
+ :@splat=>nil,
225
+ :@line=>1,
226
+ :@left=>
227
+ {:arrayliteral=>
228
+ {:@body=>
229
+ [{:localvariableassignment=>
230
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
231
+ {:localvariableassignment=>
232
+ {:@variable=>nil, :@name=>:i, :@line=>1, :@value=>nil}},
233
+ {:localvariableassignment=>
234
+ {:@variable=>nil, :@name=>:j, :@line=>1, :@value=>nil}}],
235
+ :@line=>1}},
236
+ :@right=>
237
+ {:arrayliteral=>
238
+ {:@body=>
239
+ [{:emptyarray=>{:@line=>1}},
240
+ {:fixnumliteral=>{:@line=>1, :@value=>1}},
241
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
242
+ :@line=>1}}}},
243
+ {:masgn=>
244
+ {:@block=>nil,
245
+ :@fixed=>true,
246
+ :@splat=>nil,
247
+ :@line=>2,
248
+ :@left=>
249
+ {:arrayliteral=>
250
+ {:@body=>
251
+ [{:elementassignment=>
252
+ {:@name=>:[]=,
253
+ :@line=>2,
254
+ :@privately=>false,
255
+ :@receiver=>
256
+ {:localvariableaccess=>
257
+ {:@variable=>nil, :@name=>:a, :@line=>2}},
258
+ :@arguments=>
259
+ {:actualarguments=>
260
+ {:@array=>
261
+ [{:localvariableaccess=>
262
+ {:@variable=>nil, :@name=>:i, :@line=>2}}],
263
+ :@splat=>nil,
264
+ :@line=>2}}}},
265
+ {:elementassignment=>
266
+ {:@name=>:[]=,
267
+ :@line=>2,
268
+ :@privately=>false,
269
+ :@receiver=>
270
+ {:localvariableaccess=>
271
+ {:@variable=>nil, :@name=>:a, :@line=>2}},
272
+ :@arguments=>
273
+ {:actualarguments=>
274
+ {:@array=>
275
+ [{:localvariableaccess=>
276
+ {:@variable=>nil, :@name=>:j, :@line=>2}}],
277
+ :@splat=>nil,
278
+ :@line=>2}}}}],
279
+ :@line=>2}},
280
+ :@right=>
281
+ {:arrayliteral=>
282
+ {:@body=>
283
+ [{:sendwitharguments=>
284
+ {:@block=>nil,
285
+ :@name=>:[],
286
+ :@line=>2,
287
+ :@privately=>false,
288
+ :@receiver=>
289
+ {:localvariableaccess=>
290
+ {:@variable=>nil, :@name=>:a, :@line=>2}},
291
+ :@check_for_local=>false,
292
+ :@arguments=>
293
+ {:actualarguments=>
294
+ {:@array=>
295
+ [{:localvariableaccess=>
296
+ {:@variable=>nil, :@name=>:j, :@line=>2}}],
297
+ :@splat=>nil,
298
+ :@line=>2}}}},
299
+ {:sendwitharguments=>
300
+ {:@block=>nil,
301
+ :@name=>:[],
302
+ :@line=>2,
303
+ :@privately=>false,
304
+ :@receiver=>
305
+ {:localvariableaccess=>
306
+ {:@variable=>nil, :@name=>:a, :@line=>2}},
307
+ :@check_for_local=>false,
308
+ :@arguments=>
309
+ {:actualarguments=>
310
+ {:@array=>
311
+ [{:localvariableaccess=>
312
+ {:@variable=>nil, :@name=>:i, :@line=>2}}],
313
+ :@splat=>nil,
314
+ :@line=>2}}}}],
315
+ :@line=>2}}}}],
316
+ :@line=>1}}
317
+
318
+ ruby.should parse_as(ast)
319
+ end
320
+
321
+ it 'should correctly parse "c, d, e, f = [], 1, 2, 3; a, *b = c[d] = f(e, f, c)"' do
322
+ ruby = <<-ruby
323
+ c, d, e, f = [], 1, 2, 3
324
+ a, *b = c[d] = f(e, f, c)
325
+ ruby
326
+ ast = {:block=>
327
+ {:@array=>
328
+ [{:masgn=>
329
+ {:@block=>nil,
330
+ :@fixed=>true,
331
+ :@splat=>nil,
332
+ :@line=>1,
333
+ :@left=>
334
+ {:arrayliteral=>
335
+ {:@body=>
336
+ [{:localvariableassignment=>
337
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}},
338
+ {:localvariableassignment=>
339
+ {:@variable=>nil, :@name=>:d, :@line=>1, :@value=>nil}},
340
+ {:localvariableassignment=>
341
+ {:@variable=>nil, :@name=>:e, :@line=>1, :@value=>nil}},
342
+ {:localvariableassignment=>
343
+ {:@variable=>nil, :@name=>:f, :@line=>1, :@value=>nil}}],
344
+ :@line=>1}},
345
+ :@right=>
346
+ {:arrayliteral=>
347
+ {:@body=>
348
+ [{:emptyarray=>{:@line=>1}},
349
+ {:fixnumliteral=>{:@line=>1, :@value=>1}},
350
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
351
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
352
+ :@line=>1}}}},
353
+ {:masgn=>
354
+ {:@block=>nil,
355
+ :@fixed=>false,
356
+ :@splat=>
357
+ {:splatassignment=>
358
+ {:@line=>2,
359
+ :@value=>
360
+ {:localvariableassignment=>
361
+ {:@variable=>nil, :@name=>:b, :@line=>2, :@value=>nil}}}},
362
+ :@line=>2,
363
+ :@left=>
364
+ {:arrayliteral=>
365
+ {:@body=>
366
+ [{:localvariableassignment=>
367
+ {:@variable=>nil, :@name=>:a, :@line=>2, :@value=>nil}}],
368
+ :@line=>2}},
369
+ :@right=>
370
+ {:toarray=>
371
+ {:@line=>2,
372
+ :@value=>
373
+ {:elementassignment=>
374
+ {:@name=>:[]=,
375
+ :@line=>2,
376
+ :@privately=>false,
377
+ :@receiver=>
378
+ {:localvariableaccess=>
379
+ {:@variable=>nil, :@name=>:c, :@line=>2}},
380
+ :@arguments=>
381
+ {:actualarguments=>
382
+ {:@array=>
383
+ [{:localvariableaccess=>
384
+ {:@variable=>nil, :@name=>:d, :@line=>2}},
385
+ {:sendwitharguments=>
386
+ {:@block=>nil,
387
+ :@name=>:f,
388
+ :@line=>2,
389
+ :@privately=>true,
390
+ :@receiver=>{:self=>{:@line=>2}},
391
+ :@check_for_local=>false,
392
+ :@arguments=>
393
+ {:actualarguments=>
394
+ {:@array=>
395
+ [{:localvariableaccess=>
396
+ {:@variable=>nil, :@name=>:e, :@line=>2}},
397
+ {:localvariableaccess=>
398
+ {:@variable=>nil, :@name=>:f, :@line=>2}},
399
+ {:localvariableaccess=>
400
+ {:@variable=>nil, :@name=>:c, :@line=>2}}],
401
+ :@splat=>nil,
402
+ :@line=>2}}}}],
403
+ :@splat=>nil,
404
+ :@line=>2}}}}}}}}],
405
+ :@line=>1}}
406
+
407
+ ruby.should parse_as(ast)
408
+ end
409
+
410
+ it 'should correctly parse "a, b.c = d, e"' do
411
+ ruby = 'a, b.c = d, e'
412
+ ast = {:masgn=>
413
+ {:@block=>nil,
414
+ :@fixed=>true,
415
+ :@splat=>nil,
416
+ :@line=>1,
417
+ :@left=>
418
+ {:arrayliteral=>
419
+ {:@body=>
420
+ [{:localvariableassignment=>
421
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
422
+ {:attributeassignment=>
423
+ {:@name=>:c=,
424
+ :@line=>1,
425
+ :@privately=>false,
426
+ :@receiver=>
427
+ {:send=>
428
+ {:@block=>nil,
429
+ :@name=>:b,
430
+ :@line=>1,
431
+ :@privately=>true,
432
+ :@receiver=>{:self=>{:@line=>1}},
433
+ :@check_for_local=>false}},
434
+ :@arguments=>
435
+ {:actualarguments=>{:@array=>[], :@splat=>nil, :@line=>1}}}}],
436
+ :@line=>1}},
437
+ :@right=>
438
+ {:arrayliteral=>
439
+ {:@body=>
440
+ [{:send=>
441
+ {:@block=>nil,
442
+ :@name=>:d,
443
+ :@line=>1,
444
+ :@privately=>true,
445
+ :@receiver=>{:self=>{:@line=>1}},
446
+ :@check_for_local=>false}},
447
+ {:send=>
448
+ {:@block=>nil,
449
+ :@name=>:e,
450
+ :@line=>1,
451
+ :@privately=>true,
452
+ :@receiver=>{:self=>{:@line=>1}},
453
+ :@check_for_local=>false}}],
454
+ :@line=>1}}}}
455
+
456
+ ruby.should parse_as(ast)
457
+ end
458
+
459
+ it 'should correctly parse "*a.m = *b"' do
460
+ ruby = '*a.m = *b'
461
+ ast = {:masgn=>
462
+ {:@block=>nil,
463
+ :@fixed=>false,
464
+ :@splat=>
465
+ {:attributeassignment=>
466
+ {:@name=>:m=,
467
+ :@line=>1,
468
+ :@privately=>false,
469
+ :@receiver=>
470
+ {:send=>
471
+ {:@block=>nil,
472
+ :@name=>:a,
473
+ :@line=>1,
474
+ :@privately=>true,
475
+ :@receiver=>{:self=>{:@line=>1}},
476
+ :@check_for_local=>false}},
477
+ :@arguments=>
478
+ {:actualarguments=>{:@array=>[], :@splat=>nil, :@line=>1}}}},
479
+ :@line=>1,
480
+ :@left=>nil,
481
+ :@right=>
482
+ {:splatvalue=>
483
+ {:@line=>1,
484
+ :@value=>
485
+ {:send=>
486
+ {:@block=>nil,
487
+ :@name=>:b,
488
+ :@line=>1,
489
+ :@privately=>true,
490
+ :@receiver=>{:self=>{:@line=>1}},
491
+ :@check_for_local=>false}}}}}}
492
+
493
+ ruby.should parse_as(ast)
494
+ end
495
+
496
+ it 'should correctly parse "*a.m = b"' do
497
+ ruby = '*a.m = b'
498
+ ast = {:masgn=>
499
+ {:@block=>nil,
500
+ :@fixed=>true,
501
+ :@splat=>
502
+ {:splatarray=>
503
+ {:@size=>1,
504
+ :@line=>1,
505
+ :@value=>
506
+ {:attributeassignment=>
507
+ {:@name=>:m=,
508
+ :@line=>1,
509
+ :@privately=>false,
510
+ :@receiver=>
511
+ {:send=>
512
+ {:@block=>nil,
513
+ :@name=>:a,
514
+ :@line=>1,
515
+ :@privately=>true,
516
+ :@receiver=>{:self=>{:@line=>1}},
517
+ :@check_for_local=>false}},
518
+ :@arguments=>
519
+ {:actualarguments=>{:@array=>[], :@splat=>nil, :@line=>1}}}}}},
520
+ :@line=>1,
521
+ :@left=>nil,
522
+ :@right=>
523
+ {:arrayliteral=>
524
+ {:@body=>
525
+ [{:send=>
526
+ {:@block=>nil,
527
+ :@name=>:b,
528
+ :@line=>1,
529
+ :@privately=>true,
530
+ :@receiver=>{:self=>{:@line=>1}},
531
+ :@check_for_local=>false}}],
532
+ :@line=>1}}}}
533
+
534
+ ruby.should parse_as(ast)
535
+ end
536
+
537
+ it 'should correctly parse "A, B, C = 1, 2, 3"' do
538
+ ruby = 'A, B, C = 1, 2, 3'
539
+ ast = {:masgn=>
540
+ {:@block=>nil,
541
+ :@fixed=>true,
542
+ :@splat=>nil,
543
+ :@line=>1,
544
+ :@left=>
545
+ {:arrayliteral=>
546
+ {:@body=>
547
+ [{:constset=>
548
+ {:@parent=>nil,
549
+ :@name=>{:constname=>{:@name=>:A, :@line=>1}},
550
+ :@line=>1,
551
+ :@value=>nil}},
552
+ {:constset=>
553
+ {:@parent=>nil,
554
+ :@name=>{:constname=>{:@name=>:B, :@line=>1}},
555
+ :@line=>1,
556
+ :@value=>nil}},
557
+ {:constset=>
558
+ {:@parent=>nil,
559
+ :@name=>{:constname=>{:@name=>:C, :@line=>1}},
560
+ :@line=>1,
561
+ :@value=>nil}}],
562
+ :@line=>1}},
563
+ :@right=>
564
+ {:arrayliteral=>
565
+ {:@body=>
566
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
567
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
568
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
569
+ :@line=>1}}}}
570
+
571
+ ruby.should parse_as(ast)
572
+ end
573
+
574
+ it 'should correctly parse "* = 1, 2"' do
575
+ ruby = '* = 1, 2'
576
+ ast = {:masgn=>
577
+ {:@block=>nil,
578
+ :@fixed=>true,
579
+ :@splat=>{:emptysplat=>{:@size=>2, :@line=>1}},
580
+ :@line=>1,
581
+ :@left=>nil,
582
+ :@right=>
583
+ {:arrayliteral=>
584
+ {:@body=>
585
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
586
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
587
+ :@line=>1}}}}
588
+
589
+ ruby.should parse_as(ast)
590
+ end
591
+
592
+ it 'should correctly parse "*$a = b"' do
593
+ ruby = '*$a = b'
594
+ ast = {:masgn=>
595
+ {:@block=>nil,
596
+ :@fixed=>true,
597
+ :@splat=>
598
+ {:splatarray=>
599
+ {:@size=>1,
600
+ :@line=>1,
601
+ :@value=>
602
+ {:globalvariableassignment=>{:@name=>:$a, :@line=>1, :@value=>nil}}}},
603
+ :@line=>1,
604
+ :@left=>nil,
605
+ :@right=>
606
+ {:arrayliteral=>
607
+ {:@body=>
608
+ [{:send=>
609
+ {:@block=>nil,
610
+ :@name=>:b,
611
+ :@line=>1,
612
+ :@privately=>true,
613
+ :@receiver=>{:self=>{:@line=>1}},
614
+ :@check_for_local=>false}}],
615
+ :@line=>1}}}}
616
+
617
+ ruby.should parse_as(ast)
618
+ end
619
+
620
+ it 'should correctly parse "*$a = *b"' do
621
+ ruby = '*$a = *b'
622
+ ast = {:masgn=>
623
+ {:@block=>nil,
624
+ :@fixed=>false,
625
+ :@splat=>
626
+ {:globalvariableassignment=>{:@name=>:$a, :@line=>1, :@value=>nil}},
627
+ :@line=>1,
628
+ :@left=>nil,
629
+ :@right=>
630
+ {:splatvalue=>
631
+ {:@line=>1,
632
+ :@value=>
633
+ {:send=>
634
+ {:@block=>nil,
635
+ :@name=>:b,
636
+ :@line=>1,
637
+ :@privately=>true,
638
+ :@receiver=>{:self=>{:@line=>1}},
639
+ :@check_for_local=>false}}}}}}
640
+
641
+ ruby.should parse_as(ast)
642
+ end
643
+
644
+ it 'should correctly parse "a, @b = c, d"' do
645
+ ruby = 'a, @b = c, d'
646
+ ast = {:masgn=>
647
+ {:@block=>nil,
648
+ :@fixed=>true,
649
+ :@splat=>nil,
650
+ :@line=>1,
651
+ :@left=>
652
+ {:arrayliteral=>
653
+ {:@body=>
654
+ [{:localvariableassignment=>
655
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
656
+ {:instancevariableassignment=>
657
+ {:@name=>:@b, :@line=>1, :@value=>nil}}],
658
+ :@line=>1}},
659
+ :@right=>
660
+ {:arrayliteral=>
661
+ {:@body=>
662
+ [{:send=>
663
+ {:@block=>nil,
664
+ :@name=>:c,
665
+ :@line=>1,
666
+ :@privately=>true,
667
+ :@receiver=>{:self=>{:@line=>1}},
668
+ :@check_for_local=>false}},
669
+ {:send=>
670
+ {:@block=>nil,
671
+ :@name=>:d,
672
+ :@line=>1,
673
+ :@privately=>true,
674
+ :@receiver=>{:self=>{:@line=>1}},
675
+ :@check_for_local=>false}}],
676
+ :@line=>1}}}}
677
+
678
+ ruby.should parse_as(ast)
679
+ end
680
+
681
+ it 'should correctly parse "*@a = b"' do
682
+ ruby = '*@a = b'
683
+ ast = {:masgn=>
684
+ {:@block=>nil,
685
+ :@fixed=>true,
686
+ :@splat=>
687
+ {:splatarray=>
688
+ {:@size=>1,
689
+ :@line=>1,
690
+ :@value=>
691
+ {:instancevariableassignment=>
692
+ {:@name=>:@a, :@line=>1, :@value=>nil}}}},
693
+ :@line=>1,
694
+ :@left=>nil,
695
+ :@right=>
696
+ {:arrayliteral=>
697
+ {:@body=>
698
+ [{:send=>
699
+ {:@block=>nil,
700
+ :@name=>:b,
701
+ :@line=>1,
702
+ :@privately=>true,
703
+ :@receiver=>{:self=>{:@line=>1}},
704
+ :@check_for_local=>false}}],
705
+ :@line=>1}}}}
706
+
707
+ ruby.should parse_as(ast)
708
+ end
709
+
710
+ it 'should correctly parse "*@a = *b"' do
711
+ ruby = '*@a = *b'
712
+ ast = {:masgn=>
713
+ {:@block=>nil,
714
+ :@fixed=>false,
715
+ :@splat=>
716
+ {:instancevariableassignment=>{:@name=>:@a, :@line=>1, :@value=>nil}},
717
+ :@line=>1,
718
+ :@left=>nil,
719
+ :@right=>
720
+ {:splatvalue=>
721
+ {:@line=>1,
722
+ :@value=>
723
+ {:send=>
724
+ {:@block=>nil,
725
+ :@name=>:b,
726
+ :@line=>1,
727
+ :@privately=>true,
728
+ :@receiver=>{:self=>{:@line=>1}},
729
+ :@check_for_local=>false}}}}}}
730
+
731
+ ruby.should parse_as(ast)
732
+ end
733
+
734
+ it 'should correctly parse "@a, $b = 1, 2"' do
735
+ ruby = '@a, $b = 1, 2'
736
+ ast = {:masgn=>
737
+ {:@block=>nil,
738
+ :@fixed=>true,
739
+ :@splat=>nil,
740
+ :@line=>1,
741
+ :@left=>
742
+ {:arrayliteral=>
743
+ {:@body=>
744
+ [{:instancevariableassignment=>{:@name=>:@a, :@line=>1, :@value=>nil}},
745
+ {:globalvariableassignment=>{:@name=>:$b, :@line=>1, :@value=>nil}}],
746
+ :@line=>1}},
747
+ :@right=>
748
+ {:arrayliteral=>
749
+ {:@body=>
750
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
751
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
752
+ :@line=>1}}}}
753
+
754
+ ruby.should parse_as(ast)
755
+ end
756
+
757
+ it 'should correctly parse "a, b = (@a = 1), @a"' do
758
+ ruby = 'a, b = (@a = 1), @a'
759
+ ast = {:masgn=>
760
+ {:@block=>nil,
761
+ :@fixed=>true,
762
+ :@splat=>nil,
763
+ :@line=>1,
764
+ :@left=>
765
+ {:arrayliteral=>
766
+ {:@body=>
767
+ [{:localvariableassignment=>
768
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
769
+ {:localvariableassignment=>
770
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
771
+ :@line=>1}},
772
+ :@right=>
773
+ {:arrayliteral=>
774
+ {:@body=>
775
+ [{:instancevariableassignment=>
776
+ {:@name=>:@a,
777
+ :@line=>1,
778
+ :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}},
779
+ {:instancevariableaccess=>{:@name=>:@a, :@line=>1}}],
780
+ :@line=>1}}}}
781
+
782
+ ruby.should parse_as(ast)
783
+ end
784
+
785
+ it 'should correctly parse "@@a, @@b = 1, 2"' do
786
+ ruby = '@@a, @@b = 1, 2'
787
+ ast = {:masgn=>
788
+ {:@block=>nil,
789
+ :@fixed=>true,
790
+ :@splat=>nil,
791
+ :@line=>1,
792
+ :@left=>
793
+ {:arrayliteral=>
794
+ {:@body=>
795
+ [{:classvariableassignment=>{:@name=>:@@a, :@line=>1, :@value=>nil}},
796
+ {:classvariableassignment=>{:@name=>:@@b, :@line=>1, :@value=>nil}}],
797
+ :@line=>1}},
798
+ :@right=>
799
+ {:arrayliteral=>
800
+ {:@body=>
801
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
802
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
803
+ :@line=>1}}}}
804
+
805
+ ruby.should parse_as(ast)
806
+ end
807
+
808
+ it 'should correctly parse "a, b, *c = 1, 2, 3"' do
809
+ ruby = 'a, b, *c = 1, 2, 3'
810
+ ast = {:masgn=>
811
+ {:@block=>nil,
812
+ :@fixed=>true,
813
+ :@splat=>
814
+ {:splatassignment=>
815
+ {:@line=>1,
816
+ :@value=>
817
+ {:localvariableassignment=>
818
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
819
+ :@line=>1,
820
+ :@left=>
821
+ {:arrayliteral=>
822
+ {:@body=>
823
+ [{:localvariableassignment=>
824
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
825
+ {:localvariableassignment=>
826
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
827
+ :@line=>1}},
828
+ :@right=>
829
+ {:arrayliteral=>
830
+ {:@body=>
831
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
832
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
833
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
834
+ :@line=>1}}}}
835
+
836
+ ruby.should parse_as(ast)
837
+ end
838
+
839
+ it 'should correctly parse "a, b, *c = 1, 2"' do
840
+ ruby = 'a, b, *c = 1, 2'
841
+ ast = {:masgn=>
842
+ {:@block=>nil,
843
+ :@fixed=>true,
844
+ :@splat=>
845
+ {:splatassignment=>
846
+ {:@line=>1,
847
+ :@value=>
848
+ {:localvariableassignment=>
849
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
850
+ :@line=>1,
851
+ :@left=>
852
+ {:arrayliteral=>
853
+ {:@body=>
854
+ [{:localvariableassignment=>
855
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
856
+ {:localvariableassignment=>
857
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
858
+ :@line=>1}},
859
+ :@right=>
860
+ {:arrayliteral=>
861
+ {:@body=>
862
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
863
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
864
+ :@line=>1}}}}
865
+
866
+ ruby.should parse_as(ast)
867
+ end
868
+
869
+ it 'should correctly parse "a, b, c, *d = 1, 2"' do
870
+ ruby = 'a, b, c, *d = 1, 2'
871
+ ast = {:masgn=>
872
+ {:@block=>nil,
873
+ :@fixed=>true,
874
+ :@splat=>
875
+ {:splatassignment=>
876
+ {:@line=>1,
877
+ :@value=>
878
+ {:localvariableassignment=>
879
+ {:@variable=>nil, :@name=>:d, :@line=>1, :@value=>nil}}}},
880
+ :@line=>1,
881
+ :@left=>
882
+ {:arrayliteral=>
883
+ {:@body=>
884
+ [{:localvariableassignment=>
885
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
886
+ {:localvariableassignment=>
887
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
888
+ {:localvariableassignment=>
889
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
890
+ :@line=>1}},
891
+ :@right=>
892
+ {:arrayliteral=>
893
+ {:@body=>
894
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
895
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
896
+ :@line=>1}}}}
897
+
898
+ ruby.should parse_as(ast)
899
+ end
900
+
901
+ it 'should correctly parse "a, b, c = *d"' do
902
+ ruby = 'a, b, c = *d'
903
+ ast = {:masgn=>
904
+ {:@block=>nil,
905
+ :@fixed=>false,
906
+ :@splat=>nil,
907
+ :@line=>1,
908
+ :@left=>
909
+ {:arrayliteral=>
910
+ {:@body=>
911
+ [{:localvariableassignment=>
912
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
913
+ {:localvariableassignment=>
914
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
915
+ {:localvariableassignment=>
916
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
917
+ :@line=>1}},
918
+ :@right=>
919
+ {:splatvalue=>
920
+ {:@line=>1,
921
+ :@value=>
922
+ {:send=>
923
+ {:@block=>nil,
924
+ :@name=>:d,
925
+ :@line=>1,
926
+ :@privately=>true,
927
+ :@receiver=>{:self=>{:@line=>1}},
928
+ :@check_for_local=>false}}}}}}
929
+
930
+ ruby.should parse_as(ast)
931
+ end
932
+
933
+ it 'should correctly parse "a, b, c = 1, *d"' do
934
+ ruby = 'a, b, c = 1, *d'
935
+ ast = {:masgn=>
936
+ {:@block=>nil,
937
+ :@fixed=>false,
938
+ :@splat=>nil,
939
+ :@line=>1,
940
+ :@left=>
941
+ {:arrayliteral=>
942
+ {:@body=>
943
+ [{:localvariableassignment=>
944
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
945
+ {:localvariableassignment=>
946
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
947
+ {:localvariableassignment=>
948
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
949
+ :@line=>1}},
950
+ :@right=>
951
+ {:concatargs=>
952
+ {:@array=>
953
+ {:arrayliteral=>
954
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}], :@line=>1}},
955
+ :@size=>1,
956
+ :@rest=>
957
+ {:send=>
958
+ {:@block=>nil,
959
+ :@name=>:d,
960
+ :@line=>1,
961
+ :@privately=>true,
962
+ :@receiver=>{:self=>{:@line=>1}},
963
+ :@check_for_local=>false}},
964
+ :@line=>1}}}}
965
+
966
+ ruby.should parse_as(ast)
967
+ end
968
+
969
+ it 'should correctly parse "a, b, *c = *d"' do
970
+ ruby = 'a, b, *c = *d'
971
+ ast = {:masgn=>
972
+ {:@block=>nil,
973
+ :@fixed=>false,
974
+ :@splat=>
975
+ {:splatassignment=>
976
+ {:@line=>1,
977
+ :@value=>
978
+ {:localvariableassignment=>
979
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
980
+ :@line=>1,
981
+ :@left=>
982
+ {:arrayliteral=>
983
+ {:@body=>
984
+ [{:localvariableassignment=>
985
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
986
+ {:localvariableassignment=>
987
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
988
+ :@line=>1}},
989
+ :@right=>
990
+ {:splatvalue=>
991
+ {:@line=>1,
992
+ :@value=>
993
+ {:send=>
994
+ {:@block=>nil,
995
+ :@name=>:d,
996
+ :@line=>1,
997
+ :@privately=>true,
998
+ :@receiver=>{:self=>{:@line=>1}},
999
+ :@check_for_local=>false}}}}}}
1000
+
1001
+ ruby.should parse_as(ast)
1002
+ end
1003
+
1004
+ it 'should correctly parse "*a = 1, 2, 3"' do
1005
+ ruby = '*a = 1, 2, 3'
1006
+ ast = {:masgn=>
1007
+ {:@block=>nil,
1008
+ :@fixed=>true,
1009
+ :@splat=>
1010
+ {:splatarray=>
1011
+ {:@size=>3,
1012
+ :@line=>1,
1013
+ :@value=>
1014
+ {:localvariableassignment=>
1015
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}},
1016
+ :@line=>1,
1017
+ :@left=>nil,
1018
+ :@right=>
1019
+ {:arrayliteral=>
1020
+ {:@body=>
1021
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1022
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
1023
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
1024
+ :@line=>1}}}}
1025
+
1026
+ ruby.should parse_as(ast)
1027
+ end
1028
+
1029
+ it 'should correctly parse "*a = b"' do
1030
+ ruby = '*a = b'
1031
+ ast = {:masgn=>
1032
+ {:@block=>nil,
1033
+ :@fixed=>true,
1034
+ :@splat=>
1035
+ {:splatarray=>
1036
+ {:@size=>1,
1037
+ :@line=>1,
1038
+ :@value=>
1039
+ {:localvariableassignment=>
1040
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}}},
1041
+ :@line=>1,
1042
+ :@left=>nil,
1043
+ :@right=>
1044
+ {:arrayliteral=>
1045
+ {:@body=>
1046
+ [{:send=>
1047
+ {:@block=>nil,
1048
+ :@name=>:b,
1049
+ :@line=>1,
1050
+ :@privately=>true,
1051
+ :@receiver=>{:self=>{:@line=>1}},
1052
+ :@check_for_local=>false}}],
1053
+ :@line=>1}}}}
1054
+
1055
+ ruby.should parse_as(ast)
1056
+ end
1057
+
1058
+ it 'should correctly parse "*a = *b"' do
1059
+ ruby = '*a = *b'
1060
+ ast = {:masgn=>
1061
+ {:@block=>nil,
1062
+ :@fixed=>false,
1063
+ :@splat=>
1064
+ {:localvariableassignment=>
1065
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1066
+ :@line=>1,
1067
+ :@left=>nil,
1068
+ :@right=>
1069
+ {:splatvalue=>
1070
+ {:@line=>1,
1071
+ :@value=>
1072
+ {:send=>
1073
+ {:@block=>nil,
1074
+ :@name=>:b,
1075
+ :@line=>1,
1076
+ :@privately=>true,
1077
+ :@receiver=>{:self=>{:@line=>1}},
1078
+ :@check_for_local=>false}}}}}}
1079
+
1080
+ ruby.should parse_as(ast)
1081
+ end
1082
+
1083
+ it 'should correctly parse "a, (b, c) = [1, [2, 3]]"' do
1084
+ ruby = 'a, (b, c) = [1, [2, 3]]'
1085
+ ast = {:masgn=>
1086
+ {:@block=>nil,
1087
+ :@fixed=>false,
1088
+ :@splat=>nil,
1089
+ :@line=>1,
1090
+ :@left=>
1091
+ {:arrayliteral=>
1092
+ {:@body=>
1093
+ [{:localvariableassignment=>
1094
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1095
+ {:masgn=>
1096
+ {:@block=>nil,
1097
+ :@fixed=>false,
1098
+ :@splat=>nil,
1099
+ :@line=>1,
1100
+ :@left=>
1101
+ {:arrayliteral=>
1102
+ {:@body=>
1103
+ [{:localvariableassignment=>
1104
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
1105
+ {:localvariableassignment=>
1106
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
1107
+ :@line=>1}},
1108
+ :@right=>nil}}],
1109
+ :@line=>1}},
1110
+ :@right=>
1111
+ {:toarray=>
1112
+ {:@line=>1,
1113
+ :@value=>
1114
+ {:arrayliteral=>
1115
+ {:@body=>
1116
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1117
+ {:arrayliteral=>
1118
+ {:@body=>
1119
+ [{:fixnumliteral=>{:@line=>1, :@value=>2}},
1120
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
1121
+ :@line=>1}}],
1122
+ :@line=>1}}}}}}
1123
+
1124
+ ruby.should parse_as(ast)
1125
+ end
1126
+
1127
+ it 'should correctly parse "a, = *[[[1]]]"' do
1128
+ ruby = 'a, = *[[[1]]]'
1129
+ ast = {:masgn=>
1130
+ {:@block=>nil,
1131
+ :@fixed=>false,
1132
+ :@splat=>nil,
1133
+ :@line=>1,
1134
+ :@left=>
1135
+ {:arrayliteral=>
1136
+ {:@body=>
1137
+ [{:localvariableassignment=>
1138
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}}],
1139
+ :@line=>1}},
1140
+ :@right=>
1141
+ {:splatvalue=>
1142
+ {:@line=>1,
1143
+ :@value=>
1144
+ {:arrayliteral=>
1145
+ {:@body=>
1146
+ [{:arrayliteral=>
1147
+ {:@body=>
1148
+ [{:arrayliteral=>
1149
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}],
1150
+ :@line=>1}}],
1151
+ :@line=>1}}],
1152
+ :@line=>1}}}}}}
1153
+
1154
+ ruby.should parse_as(ast)
1155
+ end
1156
+
1157
+ it 'should correctly parse "a, b, * = c"' do
1158
+ ruby = 'a, b, * = c'
1159
+ ast = {:masgn=>
1160
+ {:@block=>nil,
1161
+ :@fixed=>false,
1162
+ :@splat=>nil,
1163
+ :@line=>1,
1164
+ :@left=>
1165
+ {:arrayliteral=>
1166
+ {:@body=>
1167
+ [{:localvariableassignment=>
1168
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1169
+ {:localvariableassignment=>
1170
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1171
+ :@line=>1}},
1172
+ :@right=>
1173
+ {:toarray=>
1174
+ {:@line=>1,
1175
+ :@value=>
1176
+ {:send=>
1177
+ {:@block=>nil,
1178
+ :@name=>:c,
1179
+ :@line=>1,
1180
+ :@privately=>true,
1181
+ :@receiver=>{:self=>{:@line=>1}},
1182
+ :@check_for_local=>false}}}}}}
1183
+
1184
+ ruby.should parse_as(ast)
1185
+ end
1186
+
1187
+ it 'should correctly parse "a, b, = c"' do
1188
+ ruby = 'a, b, = c'
1189
+ ast = {:masgn=>
1190
+ {:@block=>nil,
1191
+ :@fixed=>false,
1192
+ :@splat=>nil,
1193
+ :@line=>1,
1194
+ :@left=>
1195
+ {:arrayliteral=>
1196
+ {:@body=>
1197
+ [{:localvariableassignment=>
1198
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1199
+ {:localvariableassignment=>
1200
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1201
+ :@line=>1}},
1202
+ :@right=>
1203
+ {:toarray=>
1204
+ {:@line=>1,
1205
+ :@value=>
1206
+ {:send=>
1207
+ {:@block=>nil,
1208
+ :@name=>:c,
1209
+ :@line=>1,
1210
+ :@privately=>true,
1211
+ :@receiver=>{:self=>{:@line=>1}},
1212
+ :@check_for_local=>false}}}}}}
1213
+
1214
+ ruby.should parse_as(ast)
1215
+ end
1216
+
1217
+ it 'should correctly parse "a, b, c = m d"' do
1218
+ ruby = 'a, b, c = m d'
1219
+ ast = {:masgn=>
1220
+ {:@block=>nil,
1221
+ :@fixed=>false,
1222
+ :@splat=>nil,
1223
+ :@line=>1,
1224
+ :@left=>
1225
+ {:arrayliteral=>
1226
+ {:@body=>
1227
+ [{:localvariableassignment=>
1228
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1229
+ {:localvariableassignment=>
1230
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
1231
+ {:localvariableassignment=>
1232
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
1233
+ :@line=>1}},
1234
+ :@right=>
1235
+ {:toarray=>
1236
+ {:@line=>1,
1237
+ :@value=>
1238
+ {:sendwitharguments=>
1239
+ {:@block=>nil,
1240
+ :@name=>:m,
1241
+ :@line=>1,
1242
+ :@privately=>true,
1243
+ :@receiver=>{:self=>{:@line=>1}},
1244
+ :@check_for_local=>false,
1245
+ :@arguments=>
1246
+ {:actualarguments=>
1247
+ {:@array=>
1248
+ [{:send=>
1249
+ {:@block=>nil,
1250
+ :@name=>:d,
1251
+ :@line=>1,
1252
+ :@privately=>true,
1253
+ :@receiver=>{:self=>{:@line=>1}},
1254
+ :@check_for_local=>false}}],
1255
+ :@splat=>nil,
1256
+ :@line=>1}}}}}}}}
1257
+
1258
+ ruby.should parse_as(ast)
1259
+ end
1260
+
1261
+ it 'should correctly parse "a, b, *c = d, e, f, g"' do
1262
+ ruby = 'a, b, *c = d, e, f, g'
1263
+ ast = {:masgn=>
1264
+ {:@block=>nil,
1265
+ :@fixed=>true,
1266
+ :@splat=>
1267
+ {:splatassignment=>
1268
+ {:@line=>1,
1269
+ :@value=>
1270
+ {:localvariableassignment=>
1271
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1272
+ :@line=>1,
1273
+ :@left=>
1274
+ {:arrayliteral=>
1275
+ {:@body=>
1276
+ [{:localvariableassignment=>
1277
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1278
+ {:localvariableassignment=>
1279
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1280
+ :@line=>1}},
1281
+ :@right=>
1282
+ {:arrayliteral=>
1283
+ {:@body=>
1284
+ [{:send=>
1285
+ {:@block=>nil,
1286
+ :@name=>:d,
1287
+ :@line=>1,
1288
+ :@privately=>true,
1289
+ :@receiver=>{:self=>{:@line=>1}},
1290
+ :@check_for_local=>false}},
1291
+ {:send=>
1292
+ {:@block=>nil,
1293
+ :@name=>:e,
1294
+ :@line=>1,
1295
+ :@privately=>true,
1296
+ :@receiver=>{:self=>{:@line=>1}},
1297
+ :@check_for_local=>false}},
1298
+ {:send=>
1299
+ {:@block=>nil,
1300
+ :@name=>:f,
1301
+ :@line=>1,
1302
+ :@privately=>true,
1303
+ :@receiver=>{:self=>{:@line=>1}},
1304
+ :@check_for_local=>false}},
1305
+ {:send=>
1306
+ {:@block=>nil,
1307
+ :@name=>:g,
1308
+ :@line=>1,
1309
+ :@privately=>true,
1310
+ :@receiver=>{:self=>{:@line=>1}},
1311
+ :@check_for_local=>false}}],
1312
+ :@line=>1}}}}
1313
+
1314
+ ruby.should parse_as(ast)
1315
+ end
1316
+
1317
+ it 'should correctly parse "a, b, *c = d.e("f")"' do
1318
+ ruby = 'a, b, *c = d.e("f")'
1319
+ ast = {:masgn=>
1320
+ {:@block=>nil,
1321
+ :@fixed=>false,
1322
+ :@splat=>
1323
+ {:splatassignment=>
1324
+ {:@line=>1,
1325
+ :@value=>
1326
+ {:localvariableassignment=>
1327
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1328
+ :@line=>1,
1329
+ :@left=>
1330
+ {:arrayliteral=>
1331
+ {:@body=>
1332
+ [{:localvariableassignment=>
1333
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1334
+ {:localvariableassignment=>
1335
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1336
+ :@line=>1}},
1337
+ :@right=>
1338
+ {:toarray=>
1339
+ {:@line=>1,
1340
+ :@value=>
1341
+ {:sendwitharguments=>
1342
+ {:@block=>nil,
1343
+ :@name=>:e,
1344
+ :@line=>1,
1345
+ :@privately=>false,
1346
+ :@receiver=>
1347
+ {:send=>
1348
+ {:@block=>nil,
1349
+ :@name=>:d,
1350
+ :@line=>1,
1351
+ :@privately=>true,
1352
+ :@receiver=>{:self=>{:@line=>1}},
1353
+ :@check_for_local=>false}},
1354
+ :@check_for_local=>false,
1355
+ :@arguments=>
1356
+ {:actualarguments=>
1357
+ {:@array=>[{:stringliteral=>{:@string=>:f, :@line=>1}}],
1358
+ :@splat=>nil,
1359
+ :@line=>1}}}}}}}}
1360
+
1361
+ ruby.should parse_as(ast)
1362
+ end
1363
+
1364
+ it 'should correctly parse "a, b, *c = d"' do
1365
+ ruby = 'a, b, *c = d'
1366
+ ast = {:masgn=>
1367
+ {:@block=>nil,
1368
+ :@fixed=>false,
1369
+ :@splat=>
1370
+ {:splatassignment=>
1371
+ {:@line=>1,
1372
+ :@value=>
1373
+ {:localvariableassignment=>
1374
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1375
+ :@line=>1,
1376
+ :@left=>
1377
+ {:arrayliteral=>
1378
+ {:@body=>
1379
+ [{:localvariableassignment=>
1380
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1381
+ {:localvariableassignment=>
1382
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1383
+ :@line=>1}},
1384
+ :@right=>
1385
+ {:toarray=>
1386
+ {:@line=>1,
1387
+ :@value=>
1388
+ {:send=>
1389
+ {:@block=>nil,
1390
+ :@name=>:d,
1391
+ :@line=>1,
1392
+ :@privately=>true,
1393
+ :@receiver=>{:self=>{:@line=>1}},
1394
+ :@check_for_local=>false}}}}}}
1395
+
1396
+ ruby.should parse_as(ast)
1397
+ end
1398
+
1399
+ it 'should correctly parse "a, b = c"' do
1400
+ ruby = 'a, b = c'
1401
+ ast = {:masgn=>
1402
+ {:@block=>nil,
1403
+ :@fixed=>false,
1404
+ :@splat=>nil,
1405
+ :@line=>1,
1406
+ :@left=>
1407
+ {:arrayliteral=>
1408
+ {:@body=>
1409
+ [{:localvariableassignment=>
1410
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1411
+ {:localvariableassignment=>
1412
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1413
+ :@line=>1}},
1414
+ :@right=>
1415
+ {:toarray=>
1416
+ {:@line=>1,
1417
+ :@value=>
1418
+ {:send=>
1419
+ {:@block=>nil,
1420
+ :@name=>:c,
1421
+ :@line=>1,
1422
+ :@privately=>true,
1423
+ :@receiver=>{:self=>{:@line=>1}},
1424
+ :@check_for_local=>false}}}}}}
1425
+
1426
+ ruby.should parse_as(ast)
1427
+ end
1428
+
1429
+ it 'should correctly parse "m do ..."' do
1430
+ ruby = <<-ruby
1431
+ m do
1432
+ a, b = 1, 2
1433
+ next
1434
+ end
1435
+ ruby
1436
+ ast = {:send=>
1437
+ {:@block=>
1438
+ {:iter=>
1439
+ {:@body=>
1440
+ {:block=>
1441
+ {:@array=>
1442
+ [{:masgn=>
1443
+ {:@block=>nil,
1444
+ :@fixed=>true,
1445
+ :@splat=>nil,
1446
+ :@line=>2,
1447
+ :@left=>
1448
+ {:arrayliteral=>
1449
+ {:@body=>
1450
+ [{:localvariableassignment=>
1451
+ {:@variable=>nil,
1452
+ :@name=>:a,
1453
+ :@line=>2,
1454
+ :@value=>nil}},
1455
+ {:localvariableassignment=>
1456
+ {:@variable=>nil,
1457
+ :@name=>:b,
1458
+ :@line=>2,
1459
+ :@value=>nil}}],
1460
+ :@line=>2}},
1461
+ :@right=>
1462
+ {:arrayliteral=>
1463
+ {:@body=>
1464
+ [{:fixnumliteral=>{:@line=>2, :@value=>1}},
1465
+ {:fixnumliteral=>{:@line=>2, :@value=>2}}],
1466
+ :@line=>2}}}},
1467
+ {:next=>{:@line=>3, :@value=>nil}}],
1468
+ :@line=>2}},
1469
+ :@line=>1,
1470
+ :@arguments=>
1471
+ {:iterarguments=>
1472
+ {:@block=>nil,
1473
+ :@arity=>-1,
1474
+ :@prelude=>nil,
1475
+ :@optional=>0,
1476
+ :@splat=>nil,
1477
+ :@line=>1,
1478
+ :@splat_index=>-2,
1479
+ :@required_args=>0}}}},
1480
+ :@name=>:m,
1481
+ :@line=>1,
1482
+ :@privately=>true,
1483
+ :@receiver=>{:self=>{:@line=>1}},
1484
+ :@check_for_local=>false}}
1485
+
1486
+ ruby.should parse_as(ast)
1487
+ end
1488
+
1489
+ it 'should correctly parse "a, (b, c) = 1"' do
1490
+ ruby = 'a, (b, c) = 1'
1491
+ ast = {:masgn=>
1492
+ {:@block=>nil,
1493
+ :@fixed=>false,
1494
+ :@splat=>nil,
1495
+ :@line=>1,
1496
+ :@left=>
1497
+ {:arrayliteral=>
1498
+ {:@body=>
1499
+ [{:localvariableassignment=>
1500
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1501
+ {:masgn=>
1502
+ {:@block=>nil,
1503
+ :@fixed=>false,
1504
+ :@splat=>nil,
1505
+ :@line=>1,
1506
+ :@left=>
1507
+ {:arrayliteral=>
1508
+ {:@body=>
1509
+ [{:localvariableassignment=>
1510
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
1511
+ {:localvariableassignment=>
1512
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
1513
+ :@line=>1}},
1514
+ :@right=>nil}}],
1515
+ :@line=>1}},
1516
+ :@right=>
1517
+ {:toarray=>
1518
+ {:@line=>1, :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}}}}
1519
+
1520
+ ruby.should parse_as(ast)
1521
+ end
1522
+
1523
+ it 'should correctly parse "a, (b, c) = *1"' do
1524
+ ruby = 'a, (b, c) = *1'
1525
+ ast = {:masgn=>
1526
+ {:@block=>nil,
1527
+ :@fixed=>false,
1528
+ :@splat=>nil,
1529
+ :@line=>1,
1530
+ :@left=>
1531
+ {:arrayliteral=>
1532
+ {:@body=>
1533
+ [{:localvariableassignment=>
1534
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1535
+ {:masgn=>
1536
+ {:@block=>nil,
1537
+ :@fixed=>false,
1538
+ :@splat=>nil,
1539
+ :@line=>1,
1540
+ :@left=>
1541
+ {:arrayliteral=>
1542
+ {:@body=>
1543
+ [{:localvariableassignment=>
1544
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
1545
+ {:localvariableassignment=>
1546
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
1547
+ :@line=>1}},
1548
+ :@right=>nil}}],
1549
+ :@line=>1}},
1550
+ :@right=>
1551
+ {:splatvalue=>
1552
+ {:@line=>1, :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}}}}
1553
+
1554
+ ruby.should parse_as(ast)
1555
+ end
1556
+
1557
+ it 'should correctly parse "a, (b, c) = 1, 2, 3"' do
1558
+ ruby = 'a, (b, c) = 1, 2, 3'
1559
+ ast = {:masgn=>
1560
+ {:@block=>nil,
1561
+ :@fixed=>true,
1562
+ :@splat=>nil,
1563
+ :@line=>1,
1564
+ :@left=>
1565
+ {:arrayliteral=>
1566
+ {:@body=>
1567
+ [{:localvariableassignment=>
1568
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1569
+ {:masgn=>
1570
+ {:@block=>nil,
1571
+ :@fixed=>false,
1572
+ :@splat=>nil,
1573
+ :@line=>1,
1574
+ :@left=>
1575
+ {:arrayliteral=>
1576
+ {:@body=>
1577
+ [{:localvariableassignment=>
1578
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
1579
+ {:localvariableassignment=>
1580
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
1581
+ :@line=>1}},
1582
+ :@right=>nil}}],
1583
+ :@line=>1}},
1584
+ :@right=>
1585
+ {:arrayliteral=>
1586
+ {:@body=>
1587
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1588
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
1589
+ {:fixnumliteral=>{:@line=>1, :@value=>3}}],
1590
+ :@line=>1}}}}
1591
+
1592
+ ruby.should parse_as(ast)
1593
+ end
1594
+
1595
+ it 'should correctly parse "a, (b, *c), d = 1, 2, 3, 4"' do
1596
+ ruby = 'a, (b, *c), d = 1, 2, 3, 4'
1597
+ ast = {:masgn=>
1598
+ {:@block=>nil,
1599
+ :@fixed=>true,
1600
+ :@splat=>nil,
1601
+ :@line=>1,
1602
+ :@left=>
1603
+ {:arrayliteral=>
1604
+ {:@body=>
1605
+ [{:localvariableassignment=>
1606
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1607
+ {:masgn=>
1608
+ {:@block=>nil,
1609
+ :@fixed=>false,
1610
+ :@splat=>
1611
+ {:splatwrapped=>
1612
+ {:@line=>1,
1613
+ :@value=>
1614
+ {:localvariableassignment=>
1615
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1616
+ :@line=>1,
1617
+ :@left=>
1618
+ {:arrayliteral=>
1619
+ {:@body=>
1620
+ [{:localvariableassignment=>
1621
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1622
+ :@line=>1}},
1623
+ :@right=>nil}},
1624
+ {:localvariableassignment=>
1625
+ {:@variable=>nil, :@name=>:d, :@line=>1, :@value=>nil}}],
1626
+ :@line=>1}},
1627
+ :@right=>
1628
+ {:arrayliteral=>
1629
+ {:@body=>
1630
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1631
+ {:fixnumliteral=>{:@line=>1, :@value=>2}},
1632
+ {:fixnumliteral=>{:@line=>1, :@value=>3}},
1633
+ {:fixnumliteral=>{:@line=>1, :@value=>4}}],
1634
+ :@line=>1}}}}
1635
+
1636
+ ruby.should parse_as(ast)
1637
+ end
1638
+
1639
+ it 'should correctly parse "a, (b, c) = 1, *2"' do
1640
+ ruby = 'a, (b, c) = 1, *2'
1641
+ ast = {:masgn=>
1642
+ {:@block=>nil,
1643
+ :@fixed=>false,
1644
+ :@splat=>nil,
1645
+ :@line=>1,
1646
+ :@left=>
1647
+ {:arrayliteral=>
1648
+ {:@body=>
1649
+ [{:localvariableassignment=>
1650
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1651
+ {:masgn=>
1652
+ {:@block=>nil,
1653
+ :@fixed=>false,
1654
+ :@splat=>nil,
1655
+ :@line=>1,
1656
+ :@left=>
1657
+ {:arrayliteral=>
1658
+ {:@body=>
1659
+ [{:localvariableassignment=>
1660
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}},
1661
+ {:localvariableassignment=>
1662
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}],
1663
+ :@line=>1}},
1664
+ :@right=>nil}}],
1665
+ :@line=>1}},
1666
+ :@right=>
1667
+ {:concatargs=>
1668
+ {:@array=>
1669
+ {:arrayliteral=>
1670
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}], :@line=>1}},
1671
+ :@size=>1,
1672
+ :@rest=>{:fixnumliteral=>{:@line=>1, :@value=>2}},
1673
+ :@line=>1}}}}
1674
+
1675
+ ruby.should parse_as(ast)
1676
+ end
1677
+
1678
+ it 'should correctly parse "a, (b, *c) = 1"' do
1679
+ ruby = 'a, (b, *c) = 1'
1680
+ ast = {:masgn=>
1681
+ {:@block=>nil,
1682
+ :@fixed=>false,
1683
+ :@splat=>nil,
1684
+ :@line=>1,
1685
+ :@left=>
1686
+ {:arrayliteral=>
1687
+ {:@body=>
1688
+ [{:localvariableassignment=>
1689
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1690
+ {:masgn=>
1691
+ {:@block=>nil,
1692
+ :@fixed=>false,
1693
+ :@splat=>
1694
+ {:splatwrapped=>
1695
+ {:@line=>1,
1696
+ :@value=>
1697
+ {:localvariableassignment=>
1698
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1699
+ :@line=>1,
1700
+ :@left=>
1701
+ {:arrayliteral=>
1702
+ {:@body=>
1703
+ [{:localvariableassignment=>
1704
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1705
+ :@line=>1}},
1706
+ :@right=>nil}}],
1707
+ :@line=>1}},
1708
+ :@right=>
1709
+ {:toarray=>
1710
+ {:@line=>1, :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}}}}
1711
+
1712
+ ruby.should parse_as(ast)
1713
+ end
1714
+
1715
+ it 'should correctly parse "a, (b, *c) = 1, 2"' do
1716
+ ruby = 'a, (b, *c) = 1, 2'
1717
+ ast = {:masgn=>
1718
+ {:@block=>nil,
1719
+ :@fixed=>true,
1720
+ :@splat=>nil,
1721
+ :@line=>1,
1722
+ :@left=>
1723
+ {:arrayliteral=>
1724
+ {:@body=>
1725
+ [{:localvariableassignment=>
1726
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1727
+ {:masgn=>
1728
+ {:@block=>nil,
1729
+ :@fixed=>false,
1730
+ :@splat=>
1731
+ {:splatwrapped=>
1732
+ {:@line=>1,
1733
+ :@value=>
1734
+ {:localvariableassignment=>
1735
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1736
+ :@line=>1,
1737
+ :@left=>
1738
+ {:arrayliteral=>
1739
+ {:@body=>
1740
+ [{:localvariableassignment=>
1741
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1742
+ :@line=>1}},
1743
+ :@right=>nil}}],
1744
+ :@line=>1}},
1745
+ :@right=>
1746
+ {:arrayliteral=>
1747
+ {:@body=>
1748
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1749
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
1750
+ :@line=>1}}}}
1751
+
1752
+ ruby.should parse_as(ast)
1753
+ end
1754
+
1755
+ it 'should correctly parse "a, (b, *c) = *1"' do
1756
+ ruby = 'a, (b, *c) = *1'
1757
+ ast = {:masgn=>
1758
+ {:@block=>nil,
1759
+ :@fixed=>false,
1760
+ :@splat=>nil,
1761
+ :@line=>1,
1762
+ :@left=>
1763
+ {:arrayliteral=>
1764
+ {:@body=>
1765
+ [{:localvariableassignment=>
1766
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1767
+ {:masgn=>
1768
+ {:@block=>nil,
1769
+ :@fixed=>false,
1770
+ :@splat=>
1771
+ {:splatwrapped=>
1772
+ {:@line=>1,
1773
+ :@value=>
1774
+ {:localvariableassignment=>
1775
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1776
+ :@line=>1,
1777
+ :@left=>
1778
+ {:arrayliteral=>
1779
+ {:@body=>
1780
+ [{:localvariableassignment=>
1781
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1782
+ :@line=>1}},
1783
+ :@right=>nil}}],
1784
+ :@line=>1}},
1785
+ :@right=>
1786
+ {:splatvalue=>
1787
+ {:@line=>1, :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}}}}
1788
+
1789
+ ruby.should parse_as(ast)
1790
+ end
1791
+
1792
+ it 'should correctly parse "a, (b, *c) = 1, *2"' do
1793
+ ruby = 'a, (b, *c) = 1, *2'
1794
+ ast = {:masgn=>
1795
+ {:@block=>nil,
1796
+ :@fixed=>false,
1797
+ :@splat=>nil,
1798
+ :@line=>1,
1799
+ :@left=>
1800
+ {:arrayliteral=>
1801
+ {:@body=>
1802
+ [{:localvariableassignment=>
1803
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1804
+ {:masgn=>
1805
+ {:@block=>nil,
1806
+ :@fixed=>false,
1807
+ :@splat=>
1808
+ {:splatwrapped=>
1809
+ {:@line=>1,
1810
+ :@value=>
1811
+ {:localvariableassignment=>
1812
+ {:@variable=>nil, :@name=>:c, :@line=>1, :@value=>nil}}}},
1813
+ :@line=>1,
1814
+ :@left=>
1815
+ {:arrayliteral=>
1816
+ {:@body=>
1817
+ [{:localvariableassignment=>
1818
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}],
1819
+ :@line=>1}},
1820
+ :@right=>nil}}],
1821
+ :@line=>1}},
1822
+ :@right=>
1823
+ {:concatargs=>
1824
+ {:@array=>
1825
+ {:arrayliteral=>
1826
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}], :@line=>1}},
1827
+ :@size=>1,
1828
+ :@rest=>{:fixnumliteral=>{:@line=>1, :@value=>2}},
1829
+ :@line=>1}}}}
1830
+
1831
+ ruby.should parse_as(ast)
1832
+ end
1833
+
1834
+ it 'should correctly parse "a, (*b) = 1"' do
1835
+ ruby = 'a, (*b) = 1'
1836
+ ast = {:masgn=>
1837
+ {:@block=>nil,
1838
+ :@fixed=>false,
1839
+ :@splat=>nil,
1840
+ :@line=>1,
1841
+ :@left=>
1842
+ {:arrayliteral=>
1843
+ {:@body=>
1844
+ [{:localvariableassignment=>
1845
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1846
+ {:masgn=>
1847
+ {:@block=>nil,
1848
+ :@fixed=>false,
1849
+ :@splat=>
1850
+ {:splatwrapped=>
1851
+ {:@line=>1,
1852
+ :@value=>
1853
+ {:localvariableassignment=>
1854
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}}},
1855
+ :@line=>1,
1856
+ :@left=>nil,
1857
+ :@right=>nil}}],
1858
+ :@line=>1}},
1859
+ :@right=>
1860
+ {:toarray=>
1861
+ {:@line=>1, :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}}}}
1862
+
1863
+ ruby.should parse_as(ast)
1864
+ end
1865
+
1866
+ it 'should correctly parse "a, (*b) = 1, 2"' do
1867
+ ruby = 'a, (*b) = 1, 2'
1868
+ ast = {:masgn=>
1869
+ {:@block=>nil,
1870
+ :@fixed=>true,
1871
+ :@splat=>nil,
1872
+ :@line=>1,
1873
+ :@left=>
1874
+ {:arrayliteral=>
1875
+ {:@body=>
1876
+ [{:localvariableassignment=>
1877
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1878
+ {:masgn=>
1879
+ {:@block=>nil,
1880
+ :@fixed=>false,
1881
+ :@splat=>
1882
+ {:splatwrapped=>
1883
+ {:@line=>1,
1884
+ :@value=>
1885
+ {:localvariableassignment=>
1886
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}}},
1887
+ :@line=>1,
1888
+ :@left=>nil,
1889
+ :@right=>nil}}],
1890
+ :@line=>1}},
1891
+ :@right=>
1892
+ {:arrayliteral=>
1893
+ {:@body=>
1894
+ [{:fixnumliteral=>{:@line=>1, :@value=>1}},
1895
+ {:fixnumliteral=>{:@line=>1, :@value=>2}}],
1896
+ :@line=>1}}}}
1897
+
1898
+ ruby.should parse_as(ast)
1899
+ end
1900
+
1901
+ it 'should correctly parse "a, (*b) = *1"' do
1902
+ ruby = 'a, (*b) = *1'
1903
+ ast = {:masgn=>
1904
+ {:@block=>nil,
1905
+ :@fixed=>false,
1906
+ :@splat=>nil,
1907
+ :@line=>1,
1908
+ :@left=>
1909
+ {:arrayliteral=>
1910
+ {:@body=>
1911
+ [{:localvariableassignment=>
1912
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1913
+ {:masgn=>
1914
+ {:@block=>nil,
1915
+ :@fixed=>false,
1916
+ :@splat=>
1917
+ {:splatwrapped=>
1918
+ {:@line=>1,
1919
+ :@value=>
1920
+ {:localvariableassignment=>
1921
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}}},
1922
+ :@line=>1,
1923
+ :@left=>nil,
1924
+ :@right=>nil}}],
1925
+ :@line=>1}},
1926
+ :@right=>
1927
+ {:splatvalue=>
1928
+ {:@line=>1, :@value=>{:fixnumliteral=>{:@line=>1, :@value=>1}}}}}}
1929
+
1930
+ ruby.should parse_as(ast)
1931
+ end
1932
+
1933
+ it 'should correctly parse "a, (*b) = 1, *2"' do
1934
+ ruby = 'a, (*b) = 1, *2'
1935
+ ast = {:masgn=>
1936
+ {:@block=>nil,
1937
+ :@fixed=>false,
1938
+ :@splat=>nil,
1939
+ :@line=>1,
1940
+ :@left=>
1941
+ {:arrayliteral=>
1942
+ {:@body=>
1943
+ [{:localvariableassignment=>
1944
+ {:@variable=>nil, :@name=>:a, :@line=>1, :@value=>nil}},
1945
+ {:masgn=>
1946
+ {:@block=>nil,
1947
+ :@fixed=>false,
1948
+ :@splat=>
1949
+ {:splatwrapped=>
1950
+ {:@line=>1,
1951
+ :@value=>
1952
+ {:localvariableassignment=>
1953
+ {:@variable=>nil, :@name=>:b, :@line=>1, :@value=>nil}}}},
1954
+ :@line=>1,
1955
+ :@left=>nil,
1956
+ :@right=>nil}}],
1957
+ :@line=>1}},
1958
+ :@right=>
1959
+ {:concatargs=>
1960
+ {:@array=>
1961
+ {:arrayliteral=>
1962
+ {:@body=>[{:fixnumliteral=>{:@line=>1, :@value=>1}}], :@line=>1}},
1963
+ :@size=>1,
1964
+ :@rest=>{:fixnumliteral=>{:@line=>1, :@value=>2}},
1965
+ :@line=>1}}}}
1966
+
1967
+ ruby.should parse_as(ast)
1968
+ end
1969
+
1970
+ end