[前][次][番号順一覧][スレッド一覧]

ruby-changes:21971

From: nobu <ko1@a...>
Date: Tue, 13 Dec 2011 05:50:19 +0900 (JST)
Subject: [ruby-changes:21971] nobu:r34020 (trunk): * vm_insnhelper.c (vm_yield_setup_block_args): splat single

nobu	2011-12-13 05:50:09 +0900 (Tue, 13 Dec 2011)

  New Revision: 34020

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34020

  Log:
    * vm_insnhelper.c (vm_yield_setup_block_args): splat single
      argument if optinal arguments are defined not only mandatory or
      post arguments.  [ruby-core:41557] [Bug #5730]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_proc.rb
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34019)
+++ ChangeLog	(revision 34020)
@@ -1,3 +1,9 @@
+Tue Dec 13 05:50:07 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_yield_setup_block_args): splat single
+	  argument if optinal arguments are defined not only mandatory or
+	  post arguments.  [ruby-core:41557] [Bug #5730]
+
 Mon Dec 12 22:35:39 2011  Shugo Maeda  <shugo@r...>
 
 	* parse.y (stmt_or_begin): changed the error message for BEGIN not
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 34019)
+++ vm_insnhelper.c	(revision 34020)
@@ -833,7 +833,7 @@
      */
     arg0 = argv[0];
     if (!(iseq->arg_simple & 0x02) &&          /* exclude {|a|} */
-            (m + iseq->arg_post_len) > 0 &&    /* this process is meaningful */
+            (m + iseq->arg_opts + iseq->arg_post_len) > 0 &&    /* this process is meaningful */
             argc == 1 && !NIL_P(ary = rb_check_array_type(arg0))) { /* rhs is only an array */
         th->mark_stack_len = argc = RARRAY_LENINT(ary);
 
Index: test/ruby/test_proc.rb
===================================================================
--- test/ruby/test_proc.rb	(revision 34019)
+++ test/ruby/test_proc.rb	(revision 34020)
@@ -405,6 +405,29 @@
     assert_equal [1, 2, [3, 4, 5], 6,7], pr.call([1,2,3,4,5,6,7])
   end
 
+  def test_proc_args_rest_post
+    pr = proc {|*a,b,c|
+      [a,b,c]
+    }
+    assert_equal [[], nil, nil], pr.call()
+    assert_equal [[], 1, nil], pr.call(1)
+    assert_equal [[], 1, 2], pr.call(1,2)
+    assert_equal [[1], 2, 3], pr.call(1,2,3)
+    assert_equal [[1, 2], 3, 4], pr.call(1,2,3,4)
+    assert_equal [[1, 2, 3], 4, 5], pr.call(1,2,3,4,5)
+    assert_equal [[1, 2, 3, 4], 5, 6], pr.call(1,2,3,4,5,6)
+    assert_equal [[1, 2, 3, 4, 5], 6,7], pr.call(1,2,3,4,5,6,7)
+
+    assert_equal [[], nil, nil], pr.call([])
+    assert_equal [[], 1, nil], pr.call([1])
+    assert_equal [[], 1, 2], pr.call([1,2])
+    assert_equal [[1], 2, 3], pr.call([1,2,3])
+    assert_equal [[1, 2], 3, 4], pr.call([1,2,3,4])
+    assert_equal [[1, 2, 3], 4, 5], pr.call([1,2,3,4,5])
+    assert_equal [[1, 2, 3, 4], 5, 6], pr.call([1,2,3,4,5,6])
+    assert_equal [[1, 2, 3, 4, 5], 6,7], pr.call([1,2,3,4,5,6,7])
+  end
+
   def test_proc_args_pos_opt
     pr = proc {|a,b,c=:c|
       [a,b,c]
@@ -426,6 +449,27 @@
     assert_equal [1, 2, 3], pr.call([1,2,3,4,5,6])
   end
 
+  def test_proc_args_opt
+    pr = proc {|a=:a,b=:b,c=:c|
+      [a,b,c]
+    }
+    assert_equal [:a, :b, :c], pr.call()
+    assert_equal [1, :b, :c], pr.call(1)
+    assert_equal [1, 2, :c], pr.call(1,2)
+    assert_equal [1, 2, 3], pr.call(1,2,3)
+    assert_equal [1, 2, 3], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3], pr.call(1,2,3,4,5)
+    assert_equal [1, 2, 3], pr.call(1,2,3,4,5,6)
+
+    assert_equal [:a, :b, :c], pr.call([])
+    assert_equal [1, :b, :c], pr.call([1])
+    assert_equal [1, 2, :c], pr.call([1,2])
+    assert_equal [1, 2, 3], pr.call([1,2,3])
+    assert_equal [1, 2, 3], pr.call([1,2,3,4])
+    assert_equal [1, 2, 3], pr.call([1,2,3,4,5])
+    assert_equal [1, 2, 3], pr.call([1,2,3,4,5,6])
+  end
+
   def test_proc_args_pos_opt_post
     pr = proc {|a,b,c=:c,d,e|
       [a,b,c,d,e]
@@ -447,6 +491,27 @@
     assert_equal [1, 2, 3, 4, 5], pr.call([1,2,3,4,5,6])
   end
 
+  def test_proc_args_opt_post
+    pr = proc {|a=:a,b=:b,c=:c,d,e|
+      [a,b,c,d,e]
+    }
+    assert_equal [:a, :b, :c, nil, nil], pr.call()
+    assert_equal [:a, :b, :c, 1, nil], pr.call(1)
+    assert_equal [:a, :b, :c, 1, 2], pr.call(1,2)
+    assert_equal [1, :b, :c, 2, 3], pr.call(1,2,3)
+    assert_equal [1, 2, :c, 3, 4], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, 4, 5], pr.call(1,2,3,4,5)
+    assert_equal [1, 2, 3, 4, 5], pr.call(1,2,3,4,5,6)
+
+    assert_equal [:a, :b, :c, nil, nil], pr.call([])
+    assert_equal [:a, :b, :c, 1, nil], pr.call([1])
+    assert_equal [:a, :b, :c, 1, 2], pr.call([1,2])
+    assert_equal [1, :b, :c, 2, 3], pr.call([1,2,3])
+    assert_equal [1, 2, :c, 3, 4], pr.call([1,2,3,4])
+    assert_equal [1, 2, 3, 4, 5], pr.call([1,2,3,4,5])
+    assert_equal [1, 2, 3, 4, 5], pr.call([1,2,3,4,5,6])
+  end
+
   def test_proc_args_pos_opt_rest
     pr = proc {|a,b,c=:c,*d|
       [a,b,c,d]
@@ -466,6 +531,25 @@
     assert_equal [1, 2, 3, [4, 5]], pr.call([1,2,3,4,5])
   end
 
+  def test_proc_args_opt_rest
+    pr = proc {|a=:a,b=:b,c=:c,*d|
+      [a,b,c,d]
+    }
+    assert_equal [:a, :b, :c, []], pr.call()
+    assert_equal [1, :b, :c, []], pr.call(1)
+    assert_equal [1, 2, :c, []], pr.call(1,2)
+    assert_equal [1, 2, 3, []], pr.call(1,2,3)
+    assert_equal [1, 2, 3, [4]], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, [4, 5]], pr.call(1,2,3,4,5)
+
+    assert_equal [:a, :b, :c, []], pr.call([])
+    assert_equal [1, :b, :c, []], pr.call([1])
+    assert_equal [1, 2, :c, []], pr.call([1,2])
+    assert_equal [1, 2, 3, []], pr.call([1,2,3])
+    assert_equal [1, 2, 3, [4]], pr.call([1,2,3,4])
+    assert_equal [1, 2, 3, [4, 5]], pr.call([1,2,3,4,5])
+  end
+
   def test_proc_args_pos_opt_rest_post
     pr = proc {|a,b,c=:c,*d,e|
       [a,b,c,d,e]
@@ -487,6 +571,27 @@
     assert_equal [1, 2, 3, [4,5], 6], pr.call([1,2,3,4,5,6])
   end
 
+  def test_proc_args_opt_rest_post
+    pr = proc {|a=:a,b=:b,c=:c,*d,e|
+      [a,b,c,d,e]
+    }
+    assert_equal [:a, :b, :c, [], nil], pr.call()
+    assert_equal [:a, :b, :c, [], 1], pr.call(1)
+    assert_equal [1, :b, :c, [], 2], pr.call(1,2)
+    assert_equal [1, 2, :c, [], 3], pr.call(1,2,3)
+    assert_equal [1, 2, 3, [], 4], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, [4], 5], pr.call(1,2,3,4,5)
+    assert_equal [1, 2, 3, [4,5], 6], pr.call(1,2,3,4,5,6)
+
+    assert_equal [:a, :b, :c, [], nil], pr.call([])
+    assert_equal [:a, :b, :c, [], 1], pr.call([1])
+    assert_equal [1, :b, :c, [], 2], pr.call([1,2])
+    assert_equal [1, 2, :c, [], 3], pr.call([1,2,3])
+    assert_equal [1, 2, 3, [], 4], pr.call([1,2,3,4])
+    assert_equal [1, 2, 3, [4], 5], pr.call([1,2,3,4,5])
+    assert_equal [1, 2, 3, [4,5], 6], pr.call([1,2,3,4,5,6])
+  end
+
   def test_proc_args_pos_block
     pr = proc {|a,b,&c|
       [a, b, c.class, c&&c.call(:x)]
@@ -497,6 +602,12 @@
     assert_equal [1, 2, NilClass, nil], pr.call(1,2,3)
     assert_equal [1, 2, NilClass, nil], pr.call(1,2,3,4)
 
+    assert_equal [nil, nil, NilClass, nil], pr.call([])
+    assert_equal [1, nil, NilClass, nil], pr.call([1])
+    assert_equal [1, 2, NilClass, nil], pr.call([1,2])
+    assert_equal [1, 2, NilClass, nil], pr.call([1,2,3])
+    assert_equal [1, 2, NilClass, nil], pr.call([1,2,3,4])
+
     assert_equal [nil, nil, Proc, :proc], (pr.call(){ :proc })
     assert_equal [1, nil, Proc, :proc], (pr.call(1){ :proc })
     assert_equal [1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
@@ -533,6 +644,23 @@
     assert_equal [1, 2, [3,4], Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
   end
 
+  def test_proc_args_rest_block
+    pr = proc {|*c,&d|
+      [c, d.class, d&&d.call(:x)]
+    }
+    assert_equal [[], NilClass, nil], pr.call()
+    assert_equal [[1], NilClass, nil], pr.call(1)
+    assert_equal [[1, 2], NilClass, nil], pr.call(1,2)
+
+    assert_equal [[], Proc, :proc], (pr.call(){ :proc })
+    assert_equal [[1], Proc, :proc], (pr.call(1){ :proc })
+    assert_equal [[1, 2], Proc, :proc], (pr.call(1, 2){ :proc })
+
+    assert_equal [[], Proc, :x], (pr.call(){|x| x})
+    assert_equal [[1], Proc, :x], (pr.call(1){|x| x})
+    assert_equal [[1, 2], Proc, :x], (pr.call(1, 2){|x| x})
+  end
+
   def test_proc_args_pos_rest_post_block
     pr = proc {|a,b,*c,d,e,&f|
       [a, b, c, d, e, f.class, f&&f.call(:x)]
@@ -562,6 +690,29 @@
     assert_equal [1, 2, [3,4], 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
   end
 
+  def test_proc_args_rest_post_block
+    pr = proc {|*c,d,e,&f|
+      [c, d, e, f.class, f&&f.call(:x)]
+    }
+    assert_equal [[], nil, nil, NilClass, nil], pr.call()
+    assert_equal [[], 1, nil, NilClass, nil], pr.call(1)
+    assert_equal [[], 1, 2, NilClass, nil], pr.call(1,2)
+    assert_equal [[1], 2, 3, NilClass, nil], pr.call(1,2,3)
+    assert_equal [[1, 2], 3, 4, NilClass, nil], pr.call(1,2,3,4)
+
+    assert_equal [[], nil, nil, Proc, :proc], (pr.call(){ :proc })
+    assert_equal [[], 1, nil, Proc, :proc], (pr.call(1){ :proc })
+    assert_equal [[], 1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
+    assert_equal [[1], 2, 3, Proc, :proc], (pr.call(1, 2, 3){ :proc })
+    assert_equal [[1, 2], 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
+
+    assert_equal [[], nil, nil, Proc, :x], (pr.call(){|x| x})
+    assert_equal [[], 1, nil, Proc, :x], (pr.call(1){|x| x})
+    assert_equal [[], 1, 2, Proc, :x], (pr.call(1, 2){|x| x})
+    assert_equal [[1], 2, 3, Proc, :x], (pr.call(1, 2, 3){|x| x})
+    assert_equal [[1, 2], 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
+  end
+
   def test_proc_args_pos_opt_block
     pr = proc {|a,b,c=:c,d=:d,&e|
       [a, b, c, d, e.class, e&&e.call(:x)]
@@ -588,6 +739,32 @@
     assert_equal [1, 2, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
   end
 
+  def test_proc_args_opt_block
+    pr = proc {|a=:a,b=:b,c=:c,d=:d,&e|
+      [a, b, c, d, e.class, e&&e.call(:x)]
+    }
+    assert_equal [:a, :b, :c, :d, NilClass, nil], pr.call()
+    assert_equal [1, :b, :c, :d, NilClass, nil], pr.call(1)
+    assert_equal [1, 2, :c, :d, NilClass, nil], pr.call(1,2)
+    assert_equal [1, 2, 3, :d, NilClass, nil], pr.call(1,2,3)
+    assert_equal [1, 2, 3, 4, NilClass, nil], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, 4, NilClass, nil], pr.call(1,2,3,4,5)
+
+    assert_equal [:a, :b, :c, :d, Proc, :proc], (pr.call(){ :proc })
+    assert_equal [1, :b, :c, :d, Proc, :proc], (pr.call(1){ :proc })
+    assert_equal [1, 2, :c, :d, Proc, :proc], (pr.call(1, 2){ :proc })
+    assert_equal [1, 2, 3, :d, Proc, :proc], (pr.call(1, 2, 3){ :proc })
+    assert_equal [1, 2, 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
+    assert_equal [1, 2, 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
+
+    assert_equal [:a, :b, :c, :d, Proc, :x], (pr.call(){|x| x})
+    assert_equal [1, :b, :c, :d, Proc, :x], (pr.call(1){|x| x})
+    assert_equal [1, 2, :c, :d, Proc, :x], (pr.call(1, 2){|x| x})
+    assert_equal [1, 2, 3, :d, Proc, :x], (pr.call(1, 2, 3){|x| x})
+    assert_equal [1, 2, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
+    assert_equal [1, 2, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
+  end
+
   def test_proc_args_pos_opt_post_block
     pr = proc {|a,b,c=:c,d=:d,e,f,&g|
       [a, b, c, d, e, f, g.class, g&&g.call(:x)]
@@ -620,6 +797,38 @@
     assert_equal [1, 2, 3, 4, 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7){|x| x})
   end
 
+  def test_proc_args_opt_post_block
+    pr = proc {|a=:a,b=:b,c=:c,d=:d,e,f,&g|
+      [a, b, c, d, e, f, g.class, g&&g.call(:x)]
+    }
+    assert_equal [:a, :b, :c, :d, nil, nil, NilClass, nil], pr.call()
+    assert_equal [:a, :b, :c, :d, 1, nil, NilClass, nil], pr.call(1)
+    assert_equal [:a, :b, :c, :d, 1, 2, NilClass, nil], pr.call(1,2)
+    assert_equal [1, :b, :c, :d, 2, 3, NilClass, nil], pr.call(1,2,3)
+    assert_equal [1, 2, :c, :d, 3, 4, NilClass, nil], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, :d, 4, 5, NilClass, nil], pr.call(1,2,3,4,5)
+    assert_equal [1, 2, 3, 4, 5, 6, NilClass, nil], pr.call(1,2,3,4,5,6)
+    assert_equal [1, 2, 3, 4, 5, 6, NilClass, nil], pr.call(1,2,3,4,5,6,7)
+
+    assert_equal [:a, :b, :c, :d, nil, nil, Proc, :proc], (pr.call(){ :proc })
+    assert_equal [:a, :b, :c, :d, 1, nil, Proc, :proc], (pr.call(1){ :proc })
+    assert_equal [:a, :b, :c, :d, 1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
+    assert_equal [1, :b, :c, :d, 2, 3, Proc, :proc], (pr.call(1, 2, 3){ :proc })
+    assert_equal [1, 2, :c, :d, 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
+    assert_equal [1, 2, 3, :d, 4, 5, Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
+    assert_equal [1, 2, 3, 4, 5, 6, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6){ :proc })
+    assert_equal [1, 2, 3, 4, 5, 6, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6, 7){ :proc })
+
+    assert_equal [:a, :b, :c, :d, nil, nil, Proc, :x], (pr.call(){|x| x})
+    assert_equal [:a, :b, :c, :d, 1, nil, Proc, :x], (pr.call(1){|x| x})
+    assert_equal [:a, :b, :c, :d, 1, 2, Proc, :x], (pr.call(1, 2){|x| x})
+    assert_equal [1, :b, :c, :d, 2, 3, Proc, :x], (pr.call(1, 2, 3){|x| x})
+    assert_equal [1, 2, :c, :d, 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
+    assert_equal [1, 2, 3, :d, 4, 5, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
+    assert_equal [1, 2, 3, 4, 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
+    assert_equal [1, 2, 3, 4, 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7){|x| x})
+  end
+
   def test_proc_args_pos_opt_rest_block
     pr = proc {|a,b,c=:c,d=:d,*e,&f|
       [a, b, c, d, e, f.class, f&&f.call(:x)]
@@ -649,6 +858,35 @@
     assert_equal [1, 2, 3, 4, [5,6], Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
   end
 
+  def test_proc_args_opt_rest_block
+    pr = proc {|a=:a,b=:b,c=:c,d=:d,*e,&f|
+      [a, b, c, d, e, f.class, f&&f.call(:x)]
+    }
+    assert_equal [:a, :b, :c, :d, [], NilClass, nil], pr.call()
+    assert_equal [1, :b, :c, :d, [], NilClass, nil], pr.call(1)
+    assert_equal [1, 2, :c, :d, [], NilClass, nil], pr.call(1,2)
+    assert_equal [1, 2, 3, :d, [], NilClass, nil], pr.call(1,2,3)
+    assert_equal [1, 2, 3, 4, [], NilClass, nil], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, 4, [5], NilClass, nil], pr.call(1,2,3,4,5)
+    assert_equal [1, 2, 3, 4, [5,6], NilClass, nil], pr.call(1,2,3,4,5,6)
+
+    assert_equal [:a, :b, :c, :d, [], Proc, :proc], (pr.call(){ :proc })
+    assert_equal [1, :b, :c, :d, [], Proc, :proc], (pr.call(1){ :proc })
+    assert_equal [1, 2, :c, :d, [], Proc, :proc], (pr.call(1, 2){ :proc })
+    assert_equal [1, 2, 3, :d, [], Proc, :proc], (pr.call(1, 2, 3){ :proc })
+    assert_equal [1, 2, 3, 4, [], Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
+    assert_equal [1, 2, 3, 4, [5], Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
+    assert_equal [1, 2, 3, 4, [5,6], Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6){ :proc })
+
+    assert_equal [:a, :b, :c, :d, [], Proc, :x], (pr.call(){|x| x})
+    assert_equal [1, :b, :c, :d, [], Proc, :x], (pr.call(1){|x| x})
+    assert_equal [1, 2, :c, :d, [], Proc, :x], (pr.call(1, 2){|x| x})
+    assert_equal [1, 2, 3, :d, [], Proc, :x], (pr.call(1, 2, 3){|x| x})
+    assert_equal [1, 2, 3, 4, [], Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
+    assert_equal [1, 2, 3, 4, [5], Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
+    assert_equal [1, 2, 3, 4, [5,6], Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
+  end
+
   def test_proc_args_pos_opt_rest_post_block
     pr = proc {|a,b,c=:c,d=:d,*e,f,g,&h|
       [a, b, c, d, e, f, g, h.class, h&&h.call(:x)]
@@ -684,6 +922,41 @@
     assert_equal [1, 2, 3, 4, [5,6], 7, 8, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7, 8){|x| x})
   end
 
+  def test_proc_args_opt_rest_post_block
+    pr = proc {|a=:a,b=:b,c=:c,d=:d,*e,f,g,&h|
+      [a, b, c, d, e, f, g, h.class, h&&h.call(:x)]
+    }
+    assert_equal [:a, :b, :c, :d, [], nil, nil, NilClass, nil], pr.call()
+    assert_equal [:a, :b, :c, :d, [], 1, nil, NilClass, nil], pr.call(1)
+    assert_equal [:a, :b, :c, :d, [], 1, 2, NilClass, nil], pr.call(1,2)
+    assert_equal [1, :b, :c, :d, [], 2, 3, NilClass, nil], pr.call(1,2,3)
+    assert_equal [1, 2, :c, :d, [], 3, 4, NilClass, nil], pr.call(1,2,3,4)
+    assert_equal [1, 2, 3, :d, [], 4, 5, NilClass, nil], pr.call(1,2,3,4,5)
+    assert_equal [1, 2, 3, 4, [], 5, 6, NilClass, nil], pr.call(1,2,3,4,5,6)
+    assert_equal [1, 2, 3, 4, [5], 6, 7, NilClass, nil], pr.call(1,2,3,4,5,6,7)
+    assert_equal [1, 2, 3, 4, [5,6], 7, 8, NilClass, nil], pr.call(1,2,3,4,5,6,7,8)
+
+    assert_equal [:a, :b, :c, :d, [], nil, nil, Proc, :proc], (pr.call(){ :proc })
+    assert_equal [:a, :b, :c, :d, [], 1, nil, Proc, :proc], (pr.call(1){ :proc })
+    assert_equal [:a, :b, :c, :d, [], 1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
+    assert_equal [1, :b, :c, :d, [], 2, 3, Proc, :proc], (pr.call(1, 2, 3){ :proc })
+    assert_equal [1, 2, :c, :d, [], 3, 4, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
+    assert_equal [1, 2, 3, :d, [], 4, 5, Proc, :proc], (pr.call(1, 2, 3, 4, 5){ :proc })
+    assert_equal [1, 2, 3, 4, [], 5, 6, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6){ :proc })
+    assert_equal [1, 2, 3, 4, [5], 6, 7, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6, 7){ :proc })
+    assert_equal [1, 2, 3, 4, [5,6], 7, 8, Proc, :proc], (pr.call(1, 2, 3, 4, 5, 6, 7, 8){ :proc })
+
+    assert_equal [:a, :b, :c, :d, [], nil, nil, Proc, :x], (pr.call(){|x| x})
+    assert_equal [:a, :b, :c, :d, [], 1, nil, Proc, :x], (pr.call(1){|x| x})
+    assert_equal [:a, :b, :c, :d, [], 1, 2, Proc, :x], (pr.call(1, 2){|x| x})
+    assert_equal [1, :b, :c, :d, [], 2, 3, Proc, :x], (pr.call(1, 2, 3){|x| x})
+    assert_equal [1, 2, :c, :d, [], 3, 4, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
+    assert_equal [1, 2, 3, :d, [], 4, 5, Proc, :x], (pr.call(1, 2, 3, 4, 5){|x| x})
+    assert_equal [1, 2, 3, 4, [], 5, 6, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6){|x| x})
+    assert_equal [1, 2, 3, 4, [5], 6, 7, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7){|x| x})
+    assert_equal [1, 2, 3, 4, [5,6], 7, 8, Proc, :x], (pr.call(1, 2, 3, 4, 5, 6, 7, 8){|x| x})
+  end
+
   def test_proc_args_pos_unleashed
     r = proc {|a,b=1,*c,d,e|
       [a,b,c,d,e]

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]