Updated MSpec source to a54f23d0.
[rbx.git] / spec / frozen / 1.8 / language / variables_spec.rb
blob9af4ff64ea5295a8d14f01f0204af0a633467416
1 require File.dirname(__FILE__) + '/../spec_helper'
2 require File.dirname(__FILE__) + '/fixtures/variables'
4 describe "Basic assignment" do
5   it "allows the rhs to be assigned to the lhs" do
6     a = nil;       a.should == nil
7     a = 1;         a.should == 1
8     a = [];        a.should == []
9     a = [1];       a.should == [1]
10     a = [nil];     a.should == [nil]
11     a = [[]];      a.should == [[]]
12     a = [1,2];     a.should == [1,2]
13     a = [*[]];     a.should == []
14     a = [*[1]];    a.should == [1]
15     a = [*[1,2]];  a.should == [1, 2]
16   end
18   it "allows the assignment of the rhs to the lhs using the rhs splat operator" do
19     a = *nil;      a.should == nil
20     a = *1;        a.should == 1
21     a = *[];       a.should == nil
22     a = *[1];      a.should == 1
23     a = *[nil];    a.should == nil
24     a = *[[]];     a.should == []
25     a = *[1,2];    a.should == [1,2]
26     a = *[*[]];    a.should == nil
27     a = *[*[1]];   a.should == 1
28     a = *[*[1,2]]; a.should == [1,2]
29   end
31   it "allows the assignment of the rhs to the lhs using the lhs splat operator" do
32     * = 1,2        # Valid syntax, but pretty useless! Nothing to test
33     *a = nil;      a.should == [nil]
34     *a = 1;        a.should == [1]
35     *a = [];       a.should == [[]]
36     *a = [1];      a.should == [[1]]
37     *a = [nil];    a.should == [[nil]]
38     *a = [[]];     a.should == [[[]]]
39     *a = [1,2];    a.should == [[1,2]]
40     *a = [*[]];    a.should == [[]]
41     *a = [*[1]];   a.should == [[1]]
42     *a = [*[1,2]]; a.should == [[1,2]]
43   end
44   
45   it "allows the assignment of rhs to the lhs using the lhs and rhs splat operators simultaneously" do
46     *a = *nil;      a.should == [nil]
47     *a = *1;        a.should == [1]
48     *a = *[];       a.should == []
49     *a = *[1];      a.should == [1]
50     *a = *[nil];    a.should == [nil]
51     *a = *[[]];     a.should == [[]]
52     *a = *[1,2];    a.should == [1,2]
53     *a = *[*[]];    a.should == []
54     *a = *[*[1]];   a.should == [1]
55     *a = *[*[1,2]]; a.should == [1,2]
56   end
58   it "allows multiple values to be assigned" do
59     a,b,*c = nil;       [a,b,c].should == [nil, nil, []]
60     a,b,*c = 1;         [a,b,c].should == [1, nil, []]
61     a,b,*c = [];        [a,b,c].should == [nil, nil, []]
62     a,b,*c = [1];       [a,b,c].should == [1, nil, []]
63     a,b,*c = [nil];     [a,b,c].should == [nil, nil, []]
64     a,b,*c = [[]];      [a,b,c].should == [[], nil, []]
65     a,b,*c = [1,2];     [a,b,c].should == [1,2,[]]
66     a,b,*c = [*[]];     [a,b,c].should == [nil, nil, []]
67     a,b,*c = [*[1]];    [a,b,c].should == [1, nil, []]
68     a,b,*c = [*[1,2]];  [a,b,c].should == [1, 2, []]
69     
70     a,b,*c = *nil;      [a,b,c].should == [nil, nil, []]
71     a,b,*c = *1;        [a,b,c].should == [1, nil, []]
72     a,b,*c = *[];       [a,b,c].should == [nil, nil, []]
73     a,b,*c = *[1];      [a,b,c].should == [1, nil, []]
74     a,b,*c = *[nil];    [a,b,c].should == [nil, nil, []]
75     a,b,*c = *[[]];     [a,b,c].should == [[], nil, []]
76     a,b,*c = *[1,2];    [a,b,c].should == [1,2,[]]
77     a,b,*c = *[*[]];    [a,b,c].should == [nil, nil, []]
78     a,b,*c = *[*[1]];   [a,b,c].should == [1, nil, []]
79     a,b,*c = *[*[1,2]]; [a,b,c].should == [1, 2, []]
80   end
81   
82   it "supports the {|r,| } form of block assignment" do
83     f = lambda {|r,| r.should == []}
84     f.call([], *[])   
85     
86     f = lambda{|x,| x}
87     f.call(42).should == 42
88     f.call([42]).should == [42]
89     f.call([[42]]).should == [[42]]
90     f.call([42,55]).should == [42,55]     
91   end
92   
93   it "allows assignment through lambda" do
94     f = lambda {|r,*l| r.should == []; l.should == [1]}
95     f.call([], *[1])
97     f = lambda{|x| x}
98     f.call(42).should == 42
99     f.call([42]).should == [42]
100     f.call([[42]]).should == [[42]]
101     f.call([42,55]).should == [42,55]
103     f = lambda{|*x| x}
104     f.call(42).should == [42]
105     f.call([42]).should == [[42]]
106     f.call([[42]]).should == [[[42]]]
107     f.call([42,55]).should == [[42,55]]
108     f.call(42,55).should == [42,55]
109   end
110   
111   it "allows chained assignment" do
112     (a = 1 + b = 2 + c = 4 + d = 8).should == 15
113     d.should == 8
114     c.should == 12
115     b.should == 14
116     a.should == 15
117   end
120 describe "Assignment using expansion" do
121   it "succeeds without conversion" do
122     *x = (1..7).to_a
123     x.should == [[1, 2, 3, 4, 5, 6, 7]]
124   end
127 describe "Assigning multiple values" do
128   it "allows parallel assignment" do
129     a, b = 1, 2
130     a.should == 1
131     b.should == 2
133     a, = 1,2
134     a.should == 1
135   end
136   
137   it "allows safe parallel swapping" do
138     a, b = 1, 2
139     a, b = b, a
140     a.should == 2
141     b.should == 1
142   end
144   it "evaluates rhs left-to-right" do
145     a = VariablesSpecs::ParAsgn.new
146     d,e,f = a.inc, a.inc, a.inc
147     d.should == 1
148     e.should == 2
149     f.should == 3
150   end
152   it "supports parallel assignment to lhs args via object.method=" do
153     a = VariablesSpecs::ParAsgn.new
154     a.x,b = 1,2
155     a.x.should == 1
156     b.should == 2
158     c = VariablesSpecs::ParAsgn.new
159     c.x,a.x = a.x,b
160     c.x.should == 1
161     a.x.should == 2 
162   end
164   it "supports parallel assignment to lhs args using []=" do
165     a = [1,2,3]
166     a[3],b = 4,5
167     a.should == [1,2,3,4]
168     b.should == 5
169   end
171   it "bundles remaining values to an array when using the splat operator" do
172     a, *b = 1, 2, 3
173     a.should == 1
174     b.should == [2, 3]
175     
176     *a = 1, 2, 3
177     a.should == [1, 2, 3]
178     
179     *a = 4
180     a.should == [4]
181     
182     *a = nil
183     a.should == [nil]
184     
185     a,=*[1]
186     a.should == 1
187     a,=*[[1]]
188     a.should == [1]
189     a,=*[[[1]]]
190     a.should == [[1]]
191   end
193   it "calls #to_ary on rhs arg if rhs has only a single arg" do
194     x = VariablesSpecs::ParAsgn.new
195     a,b,c = x
196     a.should == 1
197     b.should == 2
198     c.should == 3
200     a,b,c = x,5
201     a.should == x
202     b.should == 5
203     c.should == nil
205     a,b,c = 5,x
206     a.should == 5
207     b.should == x
208     c.should == nil
210     a,b,*c = x,5
211     a.should == x
212     b.should == 5
213     c.should == []
215     a,(*b),c = 5,x
216     a.should == 5
217     b.should == [x]
218     c.should == nil
220     a,(b,c) = 5,x
221     a.should == 5
222     b.should == 1
223     c.should == 2
225     a,(b,*c) = 5,x
226     a.should == 5
227     b.should == 1
228     c.should == [2,3,4]
230     a,(b,(*c)) = 5,x
231     a.should == 5
232     b.should == 1
233     c.should == [2]
235     a,(b,(*c),(*d)) = 5,x
236     a.should == 5
237     b.should == 1
238     c.should == [2]
239     d.should == [3]
241     a,(b,(*c),(d,*e)) = 5,x
242     a.should == 5
243     b.should == 1
244     c.should == [2]
245     d.should == 3
246     e.should == []
247   end
248     
249   it "allows complex parallel assignment" do
250     a, (b, c), d = 1, [2, 3], 4
251     a.should == 1
252     b.should == 2
253     c.should == 3
254     d.should == 4
255     
256     x, (y, z) = 1, 2, 3
257     [x,y,z].should == [1,2,nil]
258     x, (y, z) = 1, [2,3]
259     [x,y,z].should == [1,2,3]
260     x, (y, z) = 1, [2]
261     [x,y,z].should == [1,2,nil]
263     a,(b,c,*d),(e,f),*g = 0,[1,2,3,4],[5,6],7,8
264     a.should == 0
265     b.should == 1
266     c.should == 2
267     d.should == [3,4]
268     e.should == 5
269     f.should == 6
270     g.should == [7,8]
272     x = VariablesSpecs::ParAsgn.new
273     a,(b,c,*d),(e,f),*g = 0,x,[5,6],7,8
274     a.should == 0
275     b.should == 1
276     c.should == 2
277     d.should == [3,4]
278     e.should == 5
279     f.should == 6
280     g.should == [7,8]
281   end
283   it "allows a lhs arg to be used in another lhs args parallel assignment" do
284     c = [4,5,6]
285     a,b,c[a] = 1,2,3
286     a.should == 1
287     b.should == 2
288     c.should == [4,3,6]
290     c[a],b,a = 7,8,9
291     a.should == 9
292     b.should == 8
293     c.should == [4,7,6]
294   end
297 describe "Conditional assignment" do
298   it "assigns the lhs if previously unassigned" do
299     a=[]
300     a[0] ||= "bar"
301     a[0].should == "bar"
303     h={}
304     h["foo"] ||= "bar"
305     h["foo"].should == "bar"
307     h["foo".to_sym] ||= "bar"
308     h["foo".to_sym].should == "bar"
310     aa = 5
311     aa ||= 25
312     aa.should == 5
314     bb ||= 25
315     bb.should == 25
317     cc &&=33
318     cc.should == nil
320     cc = 5
321     cc &&=44
322     cc.should == 44
323   end
325   it "checks for class variable definition before fetching its value" do
326     class VariableSpecCVarSpec
327       @@cvarspec ||= 5
328       @@cvarspec.should == 5
329     end
330   end
333 describe "Operator assignment 'var op= expr'" do
334   it "is equivalent to 'var = var op expr'" do
335     x = 13
336     (x += 5).should == 18
337     x.should == 18
339     x = 17
340     (x -= 11).should == 6
341     x.should == 6
343     x = 2
344     (x *= 5).should == 10
345     x.should == 10
347     x = 36
348     (x /= 9).should == 4
349     x.should == 4
351     x = 23
352     (x %= 5).should == 3
353     x.should == 3
354     (x %= 3).should == 0
355     x.should == 0
357     x = 2
358     (x **= 3).should == 8
359     x.should == 8
361     x = 4
362     (x |= 3).should == 7
363     x.should == 7
364     (x |= 4).should == 7
365     x.should == 7
367     x = 6
368     (x &= 3).should == 2
369     x.should == 2
370     (x &= 4).should == 0
371     x.should == 0
373     # XOR
374     x = 2
375     (x ^= 3).should == 1
376     x.should == 1
377     (x ^= 4).should == 5
378     x.should == 5
380     # Bit-shift left
381     x = 17
382     (x <<= 3).should == 136
383     x.should == 136
385     # Bit-shift right
386     x = 5
387     (x >>= 1).should == 2
388     x.should == 2
390     x = nil
391     (x ||= 17).should == 17
392     x.should == 17
393     (x ||= 2).should == 17
394     x.should == 17
396     x = false
397     (x &&= true).should == false
398     x.should == false
399     (x &&= false).should == false
400     x.should == false
401     x = true
402     (x &&= true).should == true
403     x.should == true
404     (x &&= false).should == false
405     x.should == false
406   end
407   
408   it "uses short-circuit arg evaluation for operators ||= and &&=" do
409     x = 8
410     y = VariablesSpecs::OpAsgn.new
411     (x ||= y.do_side_effect).should == 8
412     y.side_effect.should == nil
413     
414     x = nil
415     (x &&= y.do_side_effect).should == nil
416     y.side_effect.should == nil
418     y.a = 5
419     (x ||= y.do_side_effect).should == 5
420     y.side_effect.should == true
421   end
424 describe "Operator assignment 'obj.meth op= expr'" do
425   it "is equivalent to 'obj.meth = obj.meth op expr'" do
426     @x = VariablesSpecs::OpAsgn.new
427     @x.a = 13
428     (@x.a += 5).should == 18
429     @x.a.should == 18
431     @x.a = 17
432     (@x.a -= 11).should == 6
433     @x.a.should == 6
435     @x.a = 2
436     (@x.a *= 5).should == 10
437     @x.a.should == 10
439     @x.a = 36
440     (@x.a /= 9).should == 4
441     @x.a.should == 4
443     @x.a = 23
444     (@x.a %= 5).should == 3
445     @x.a.should == 3
446     (@x.a %= 3).should == 0
447     @x.a.should == 0
449     @x.a = 2
450     (@x.a **= 3).should == 8
451     @x.a.should == 8
453     @x.a = 4
454     (@x.a |= 3).should == 7
455     @x.a.should == 7
456     (@x.a |= 4).should == 7
457     @x.a.should == 7
459     @x.a = 6
460     (@x.a &= 3).should == 2
461     @x.a.should == 2
462     (@x.a &= 4).should == 0
463     @x.a.should == 0
465     # XOR
466     @x.a = 2
467     (@x.a ^= 3).should == 1
468     @x.a.should == 1
469     (@x.a ^= 4).should == 5
470     @x.a.should == 5
472     @x.a = 17
473     (@x.a <<= 3).should == 136
474     @x.a.should == 136
476     @x.a = 5
477     (@x.a >>= 1).should == 2
478     @x.a.should == 2
480     @x.a = nil
481      (@x.a ||= 17).should == 17
482     @x.a.should == 17
483     (@x.a ||= 2).should == 17
484     @x.a.should == 17
486     @x.a = false
487     (@x.a &&= true).should == false
488     @x.a.should == false
489     (@x.a &&= false).should == false
490     @x.a.should == false
491     @x.a = true
492     (@x.a &&= true).should == true
493     @x.a.should == true
494     (@x.a &&= false).should == false
495     @x.a.should == false
496   end
497   
498   it "uses short-circuit arg evaluation for operators ||= and &&=" do
499     x = 8
500     y = VariablesSpecs::OpAsgn.new
501     (x ||= y.do_side_effect).should == 8
502     y.side_effect.should == nil
503     
504     x = nil
505     (x &&= y.do_side_effect).should == nil
506     y.side_effect.should == nil
508     y.a = 5
509     (x ||= y.do_side_effect).should == 5
510     y.side_effect.should == true
511   end
514 describe "Operator assignment 'obj[idx] op= expr'" do
515   it "is equivalent to 'obj[idx] = obj[idx] op expr'" do
516     x = [2,13,7]
517     (x[1] += 5).should == 18
518     x.should == [2,18,7]
520     x = [17,6]
521     (x[0] -= 11).should == 6
522     x.should == [6,6]
524     x = [nil,2,28]
525     (x[2] *= 2).should == 56
526     x.should == [nil,2,56]
528     x = [3,9,36]
529     (x[2] /= x[1]).should == 4
530     x.should == [3,9,4]
532     x = [23,4]
533     (x[0] %= 5).should == 3
534     x.should == [3,4]
535     (x[0] %= 3).should == 0
536     x.should == [0,4]
538     x = [1,2,3]
539     (x[1] **= 3).should == 8
540     x.should == [1,8,3]
542     x = [4,5,nil]
543     (x[0] |= 3).should == 7
544     x.should == [7,5,nil]
545     (x[0] |= 4).should == 7
546     x.should == [7,5,nil]
548     x = [3,6,9]
549     (x[1] &= 3).should == 2
550     x.should == [3,2,9]
551     (x[1] &= 4).should == 0
552     x.should == [3,0,9]
554     # XOR
555     x = [0,1,2]
556     (x[2] ^= 3).should == 1
557     x.should == [0,1,1]
558     (x[2] ^= 4).should == 5
559     x.should == [0,1,5]
561     x = [17]
562     (x[0] <<= 3).should == 136
563     x.should == [136]
565     x = [nil,5,8]
566     (x[1] >>= 1).should == 2
567     x.should == [nil,2,8]
569     x = [1,nil,12]
570     (x[1] ||= 17).should == 17
571     x.should == [1,17,12]
572     (x[1] ||= 2).should == 17
573     x.should == [1,17,12]
574   
575     x = [true, false, false]
576     (x[1] &&= true).should == false
577     x.should == [true, false, false]
578     (x[1] &&= false).should == false
579     x.should == [true, false, false]
580     (x[0] &&= true).should == true
581     x.should == [true, false, false]
582     (x[0] &&= false).should == false
583     x.should == [false, false, false]
584   end
586   it "uses short-circuit arg evaluation for operators ||= and &&=" do
587     x = 8
588     y = VariablesSpecs::OpAsgn.new
589     (x ||= y.do_side_effect).should == 8
590     y.side_effect.should == nil
591     
592     x = nil
593     (x &&= y.do_side_effect).should == nil
594     y.side_effect.should == nil
596     y.a = 5
597     (x ||= y.do_side_effect).should == 5
598     y.side_effect.should == true
599   end
601   it "handles complex index (idx) arguments" do
602     x = [1,2,3,4]
603     (x[0,2] += [5]).should == [1,2,5]
604     x.should == [1,2,5,3,4]
605     (x[0,2] += [3,4]).should == [1,2,3,4]
606     x.should == [1,2,3,4,5,3,4]
607     
608     (x[2..3] += [8]).should == [3,4,8]
609     x.should == [1,2,3,4,8,5,3,4]
610     
611     y = VariablesSpecs::OpAsgn.new
612     y.a = 1
613     (x[y.do_side_effect] *= 2).should == 4
614     x.should == [1,4,3,4,8,5,3,4]
615     
616     h = {'key1' => 23, 'key2' => 'val'}
617     (h['key1'] %= 5).should == 3
618     (h['key2'] += 'ue').should == 'value'
619     h.should == {'key1' => 3, 'key2' => 'value'}
620   end
622   it "returns result of rhs not result of []=" do
623     a = VariablesSpecs::Hashalike.new
625     (a[123] =   2).should == 2
626     (a[123] +=  2).should == 125
627     (a[123] -=  2).should == 121
628     (a[123] *=  2).should == 246
629     (a[123] /=  2).should == 61
630     (a[123] %=  2).should == 1
631     (a[123] **= 2).should == 15129
632     (a[123] |=  2).should == 123
633     (a[123] &=  2).should == 2
634     (a[123] ^=  2).should == 121
635     (a[123] <<= 2).should == 492
636     (a[123] >>= 2).should == 30
637     (a[123] ||= 2).should == 123
638     (a[nil] ||= 2).should == 2
639     (a[123] &&= 2).should == 2
640     (a[nil] &&= 2).should == nil
641   end
644 describe "Single assignment" do
645   it "Assignment does not modify the lhs, it reassigns its reference" do
646     a = 'Foobar'
647     b = a
648     b = 'Bazquux'
649     a.should == 'Foobar'
650     b.should == 'Bazquux'
651   end
653   it "Assignment does not copy the object being assigned, just creates a new reference to it" do
654     a = []
655     b = a
656     b << 1
657     a.should == [1]
658   end
660   it "If rhs has multiple arguments, lhs becomes an Array of them" do
661     a = 1, 2, 3
662     a.should == [1, 2, 3]
663   end
666 describe "Multiple assignment without grouping or splatting" do
667   it "An equal number of arguments on lhs and rhs assigns positionally" do
668     a, b, c, d = 1, 2, 3, 4
669     a.should == 1
670     b.should == 2
671     c.should == 3
672     d.should == 4
673   end 
675   it "If rhs has too few arguments, the missing ones on lhs are assigned nil" do
676     a, b, c = 1, 2
677     a.should == 1
678     b.should == 2
679     c.should == nil
680   end
682   it "If rhs has too many arguments, the extra ones are silently not assigned anywhere" do
683     a, b = 1, 2, 3
684     a.should == 1
685     b.should == 2
686   end
688   it "The assignments are done in parallel so that lhs and rhs are independent of eachother without copying" do
689     o_of_a, o_of_b = mock('a'), mock('b')
690     a, b = o_of_a, o_of_b
691     a, b = b, a
692     a.should equal(o_of_b)
693     b.should equal(o_of_a)
694   end
697 describe "Multiple assignments with splats" do
698   # TODO make this normal once rubinius eval works
699   compliant_on :ruby do
700     it "* on the lhs has to be applied to the last parameter" do
701       lambda { eval 'a, *b, c = 1, 2, 3' }.should raise_error(SyntaxError)
702     end
703   end
705   it "* on the lhs collects all parameters from its position onwards as an Array or an empty Array" do
706     a, *b = 1, 2
707     c, *d = 1
708     e, *f = 1, 2, 3
709     g, *h = 1, [2, 3]
710     *i = 1, [2,3]
711     *j = [1,2,3]
712     *k = 1,2,3
714     a.should == 1
715     b.should == [2]
716     c.should == 1
717     d.should == []
718     e.should == 1
719     f.should == [2, 3]
720     g.should == 1
721     h.should == [[2, 3]]
722     i.should == [1, [2, 3]]
723     j.should == [[1,2,3]]
724     k.should == [1,2,3]
725   end
728 describe "Multiple assignments with grouping" do
729   it "A group on the lhs is considered one position and treats its corresponding rhs position like an Array" do
730     a, (b, c), d = 1, 2, 3, 4
731     e, (f, g), h = 1, [2, 3, 4], 5
732     i, (j, k), l = 1, 2, 3
733     a.should == 1
734     b.should == 2
735     c.should == nil
736     d.should == 3
737     e.should == 1
738     f.should == 2
739     g.should == 3
740     h.should == 5
741     i.should == 1
742     j.should == 2
743     k.should == nil
744     l.should == 3
745   end
747   it "supports multiple levels of nested groupings" do
748     a,(b,(c,d)) = 1,[2,[3,4]]
749     a.should == 1
750     b.should == 2
751     c.should == 3
752     d.should == 4
754     a,(b,(c,d)) = [1,[2,[3,4]]]
755     a.should == 1
756     b.should == 2
757     c.should == 3
758     d.should == 4
760     x = [1,[2,[3,4]]]
761     a,(b,(c,d)) = x
762     a.should == 1
763     b.should == 2
764     c.should == 3
765     d.should == 4
766   end
768   compliant_on :ruby do
769     it "rhs cannot use parameter grouping, it is a syntax error" do
770       lambda { eval '(a, b) = (1, 2)' }.should raise_error(SyntaxError)
771     end
772   end
775 compliant_on :ruby do
777 describe "Multiple assignment" do
778   it "has the proper return value" do
779     (a,b,*c = *[5,6,7,8,9,10]).should == [5,6,7,8,9,10]
780     (d,e = VariablesSpecs.reverse_foo(4,3)).should == [3,4]
781     (f,g,h = VariablesSpecs.reverse_foo(6,7)).should == [7,6]
782     (i,*j = *[5,6,7]).should == [5,6,7]
783     (k,*l = [5,6,7]).should == [5,6,7]
784     a.should == 5
785     b.should == 6
786     c.should == [7,8,9,10]
787     d.should == 3
788     e.should == 4
789     f.should == 7
790     g.should == 6
791     h.should == nil
792     i.should == 5
793     j.should == [6,7]
794     k.should == 5
795     l.should == [6,7]
796   end
800 # For now, masgn is deliberately non-compliant with MRI wrt the return val from an masgn.
801 # Rubinius returns true as the result of the assignment, but MRI returns an array
802 # containing all the elements on the rhs. As this result is never used, the cost
803 # of creating and then discarding this array is avoided
804 describe "Multiple assignment, array-style" do
805   compliant_on :ruby do
806     it "returns an array of all rhs values" do
807       (a,b = 5,6,7).should == [5,6,7]
808       a.should == 5
809       b.should == 6
811       (c,d,*e = 99,8).should == [99,8]
812       c.should == 99
813       d.should == 8
814       e.should == []
816       (f,g,h = 99,8).should == [99,8]
817       f.should == 99
818       g.should == 8
819       h.should == nil
820     end
821   end
823   deviates_on :rubinius do
824     it "returns true" do
825       (a,b = 5,6,7).should == true
826       a.should == 5
827       b.should == 6
829       (c,d,*e = 99,8).should == true
830       c.should == 99
831       d.should == 8
832       e.should == []
834       (f,g,h = 99,8).should == true
835       f.should == 99
836       g.should == 8
837       h.should == nil
838     end
839   end