summaryrefslogtreecommitdiff
path: root/bootstraptest/test_massign.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-26 18:56:15 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-26 18:56:15 +0000
commit30ab3f75f9a8399c300359ea84e25f9a93df73ae (patch)
treeb3ec2146dec6a8344a47504d05f414b56cd98550 /bootstraptest/test_massign.rb
parent99c58e9ebcb90a81c2b6201d1d11ac1d5bd84604 (diff)
* compile.c (compile_massign), insns.def (expandarray): support
postarg with massign (a, *b, c = ...). * bootstraptest/test_massign.rb: add tests for above. * compile.h: fix debug macro names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest/test_massign.rb')
-rw-r--r--bootstraptest/test_massign.rb140
1 files changed, 140 insertions, 0 deletions
diff --git a/bootstraptest/test_massign.rb b/bootstraptest/test_massign.rb
new file mode 100644
index 0000000..61272a3
--- /dev/null
+++ b/bootstraptest/test_massign.rb
@@ -0,0 +1,140 @@
+=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]
+ }