2007-07-03 14:50:28 -04:00
|
|
|
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]'
|
|
|
|
|
2007-07-05 14:16:54 -04:00
|
|
|
assert_equal '[]', '*a = *nil; a'
|
|
|
|
assert_equal '[nil]', '*a = nil; a'
|
2007-08-23 03:10:56 -04:00
|
|
|
assert_equal '2', 'a, a = 1, 2; a', "[ruby-dev:31522]"
|
2007-08-24 11:19:00 -04:00
|
|
|
assert_equal '[1, 2]', 'a, b = 1, 2'
|
|
|
|
assert_equal '[1, 2]', %q{
|
|
|
|
ans = []
|
|
|
|
trace_var(:$a){|v| ans << v}
|
|
|
|
trace_var(:$b){|v| ans << v}
|
|
|
|
$a, $b = 1, 2
|
|
|
|
ans
|
|
|
|
}
|
2007-07-05 14:16:54 -04:00
|
|
|
|
2007-08-30 14:49:00 -04:00
|
|
|
assert_equal 'ok', %q{
|
|
|
|
r = :ok
|
|
|
|
:ng.tap {|(r)|}
|
|
|
|
r
|
|
|
|
}, '[ruby-dev:31507]'
|
|
|
|
|
2007-06-26 14:56:15 -04:00
|
|
|
=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]
|
|
|
|
}
|