summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 11:28:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 11:28:56 +0000
commit7fd58845d907d218538a39d829ccb4090c784618 (patch)
treed030bffc9c40969ceae98ec0e74d1915722fc6bc /test
parentc8185b327ea68ce125937c977b2b158a90f27561 (diff)
proc.c: fix arity of rest keywords argument
* proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if having rest keywords argument. [ruby-core:53298] [Bug #8072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_method.rb21
-rw-r--r--test/ruby/test_proc.rb18
2 files changed, 39 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index bb6b9ae70b..af29ce59a3 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -23,6 +23,13 @@ class TestMethod < Test::Unit::TestCase
def mo6(a, *b, c, &d) end
def mo7(a, b = nil, *c, d, &e) end
def ma1((a), &b) nil && a end
+ def mk1(**) end
+ def mk2(**o) nil && o end
+ def mk3(a, **o) nil && o end
+ def mk4(a = nil, **o) nil && o end
+ def mk5(a, b = nil, **o) nil && o end
+ def mk6(a, b = nil, c, **o) nil && o end
+ def mk7(a, b = nil, *c, d, **o) nil && o end
class Base
def foo() :base end
@@ -68,6 +75,13 @@ class TestMethod < Test::Unit::TestCase
assert_equal(-2, method(:mo4).arity)
assert_equal(-3, method(:mo5).arity)
assert_equal(-3, method(:mo6).arity)
+ assert_equal(-1, method(:mk1).arity)
+ assert_equal(-1, method(:mk2).arity)
+ assert_equal(-2, method(:mk3).arity)
+ assert_equal(-1, method(:mk4).arity)
+ assert_equal(-2, method(:mk5).arity)
+ assert_equal(-3, method(:mk6).arity)
+ assert_equal(-3, method(:mk7).arity)
end
def test_arity_special
@@ -457,6 +471,13 @@ class TestMethod < Test::Unit::TestCase
define_method(:pmo6) {|a, *b, c, &d|}
define_method(:pmo7) {|a, b = nil, *c, d, &e|}
define_method(:pma1) {|(a), &b| nil && a}
+ define_method(:pmk1) {|**|}
+ define_method(:pmk2) {|**o|}
+ define_method(:pmk3) {|a, **o|}
+ define_method(:pmk4) {|a = nil, **o|}
+ define_method(:pmk5) {|a, b = nil, **o|}
+ define_method(:pmk6) {|a, b = nil, c, **o|}
+ define_method(:pmk7) {|a, b = nil, *c, d, **o|}
def test_bound_parameters
assert_equal([], method(:m0).parameters)
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 2acce84da3..7dd93bee9d 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -77,6 +77,13 @@ class TestProc < Test::Unit::TestCase
assert_equal(2, proc{|(x, y), z|[x,y]}.arity)
assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity)
assert_equal(-4, proc{|x, *y, z, a|}.arity)
+ assert_equal(-1, proc{|**|}.arity)
+ assert_equal(-1, proc{|**o|}.arity)
+ assert_equal(-2, proc{|x, **o|}.arity)
+ assert_equal(-1, proc{|x=0, **o|}.arity)
+ assert_equal(-2, proc{|x, y=0, **o|}.arity)
+ assert_equal(-3, proc{|x, y=0, z, **o|}.arity)
+ assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity)
assert_equal(0, lambda{}.arity)
assert_equal(0, lambda{||}.arity)
@@ -95,6 +102,13 @@ class TestProc < Test::Unit::TestCase
assert_equal(2, lambda{|(x, y), z|[x,y]}.arity)
assert_equal(-2, lambda{|(x, y), z=0|[x,y]}.arity)
assert_equal(-4, lambda{|x, *y, z, a|}.arity)
+ assert_equal(-1, lambda{|**|}.arity)
+ assert_equal(-1, lambda{|**o|}.arity)
+ assert_equal(-2, lambda{|x, **o|}.arity)
+ assert_equal(-1, lambda{|x=0, **o|}.arity)
+ assert_equal(-2, lambda{|x, y=0, **o|}.arity)
+ assert_equal(-3, lambda{|x, y=0, z, **o|}.arity)
+ assert_equal(-3, lambda{|x, y=0, *z, w, **o|}.arity)
assert_arity(0) {}
assert_arity(0) {||}
@@ -104,6 +118,10 @@ class TestProc < Test::Unit::TestCase
assert_arity(-3) {|x, *y, z|}
assert_arity(-1) {|*x|}
assert_arity(-1) {|*|}
+ assert_arity(-1) {|**o|}
+ assert_arity(-1) {|**|}
+ assert_arity(-2) {|x, *y, **|}
+ assert_arity(-3) {|x, *y, z, **|}
end
def m(x)