mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
976bfae03b
* compile.c (compile_massign): fix to invoke to_splat on splat rhs (example: *a = *nil). [ruby-dev:31136] * bootstraptest/test_massign.rb: add tests for above. * compile.c (iseq_compile_each): disable excess optimization. [ruby-dev:31126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
146 lines
3.8 KiB
Ruby
146 lines
3.8 KiB
Ruby
assert_equal '[[1], 2, 3]', '*v1, (a, b) = [1,[2, 3]]; [v1, a, b]'
|
|
assert_equal '[[1], 2, 3]', '*v1,(*), (a, b) = [1,:x,[2, 3]]; [v1, a, b]'
|
|
|
|
assert_equal '[]', '*a = *nil; a'
|
|
assert_equal '[nil]', '*a = nil; a'
|
|
|
|
=begin
|
|
# generated by this script:
|
|
|
|
3.times{|i|
|
|
8.times{|e|
|
|
ary = (0...e).to_a
|
|
a,b,c,d,e,f = nil
|
|
vals = %w(a b c d e f)
|
|
vals[i] = '*' + vals[i]
|
|
program = "#{vals.join(", ")} = *ary"
|
|
eval(program)
|
|
ans = [a,b,c,d,e,f]
|
|
puts %Q{
|
|
assert_equal "#{ans.inspect}", %q{
|
|
ary = #{ary.inspect}
|
|
#{program}; [a, b, c, d, e, f]
|
|
}}
|
|
}
|
|
}
|
|
=end
|
|
|
|
assert_equal "[[], nil, nil, nil, nil, nil]", %q{
|
|
ary = []
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[], 0, nil, nil, nil, nil]", %q{
|
|
ary = [0]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[], 0, 1, nil, nil, nil]", %q{
|
|
ary = [0, 1]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[], 0, 1, 2, nil, nil]", %q{
|
|
ary = [0, 1, 2]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[], 0, 1, 2, 3, nil]", %q{
|
|
ary = [0, 1, 2, 3]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[], 0, 1, 2, 3, 4]", %q{
|
|
ary = [0, 1, 2, 3, 4]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[0], 1, 2, 3, 4, 5]", %q{
|
|
ary = [0, 1, 2, 3, 4, 5]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[[0, 1], 2, 3, 4, 5, 6]", %q{
|
|
ary = [0, 1, 2, 3, 4, 5, 6]
|
|
*a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[nil, [], nil, nil, nil, nil]", %q{
|
|
ary = []
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [], nil, nil, nil, nil]", %q{
|
|
ary = [0]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [], 1, nil, nil, nil]", %q{
|
|
ary = [0, 1]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [], 1, 2, nil, nil]", %q{
|
|
ary = [0, 1, 2]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [], 1, 2, 3, nil]", %q{
|
|
ary = [0, 1, 2, 3]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [], 1, 2, 3, 4]", %q{
|
|
ary = [0, 1, 2, 3, 4]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [1], 2, 3, 4, 5]", %q{
|
|
ary = [0, 1, 2, 3, 4, 5]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, [1, 2], 3, 4, 5, 6]", %q{
|
|
ary = [0, 1, 2, 3, 4, 5, 6]
|
|
a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[nil, nil, [], nil, nil, nil]", %q{
|
|
ary = []
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, nil, [], nil, nil, nil]", %q{
|
|
ary = [0]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, 1, [], nil, nil, nil]", %q{
|
|
ary = [0, 1]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, 1, [], 2, nil, nil]", %q{
|
|
ary = [0, 1, 2]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, 1, [], 2, 3, nil]", %q{
|
|
ary = [0, 1, 2, 3]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, 1, [], 2, 3, 4]", %q{
|
|
ary = [0, 1, 2, 3, 4]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, 1, [2], 3, 4, 5]", %q{
|
|
ary = [0, 1, 2, 3, 4, 5]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|
|
|
|
assert_equal "[0, 1, [2, 3], 4, 5, 6]", %q{
|
|
ary = [0, 1, 2, 3, 4, 5, 6]
|
|
a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
|
|
}
|