diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-22 13:13:24 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-22 13:13:24 +0000 |
commit | be2101a641bcb320521ebcd498c147b81ea96b19 (patch) | |
tree | ca883487694bce8f16d587801a1514235e408a4e /test/ruby/test_proc.rb | |
parent | 3aa457ce139a2698a7c1c22e7d928f1325830cf9 (diff) |
merge revision(s) 44412,44413,44414,44420,44421: [Backport #9298]
test_method.rb, test_proc.rb: suppress warnings
* test/ruby/test_method.rb: suppress warnings in verbose mode.
* test/ruby/test_proc.rb: ditto.
* proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if
having rest keywords argument. [ruby-core:53298] [Bug #8072]
* iseq.c (rb_iseq_parameters): push argument type symbol only for
unnamed rest keywords argument.
* compile.c (iseq_set_arguments): set arg_keyword_check from
nd_cflag, which is set by parser. internal ID is used for
unnamed keyword rest argument, which should be separated from no
keyword check.
* iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is
present.
* parse.y (new_args_tail_gen): set keywords check to nd_cflag, which
equals to that keyword rest is not present.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_proc.rb')
-rw-r--r-- | test/ruby/test_proc.rb | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index b40485f582..206e21fb1a 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) @@ -1086,6 +1104,13 @@ class TestProc < Test::Unit::TestCase def pmo6(a, *b, c, &d) end def pmo7(a, b = :b, *c, d, &e) end def pma1((a), &b) a; end + def pmk1(**) end + def pmk2(**o) nil && o end + def pmk3(a, **o) nil && o end + def pmk4(a = nil, **o) nil && o end + def pmk5(a, b = nil, **o) nil && o end + def pmk6(a, b = nil, c, **o) nil && o end + def pmk7(a, b = nil, *c, d, **o) nil && o end def test_bound_parameters @@ -1100,6 +1125,13 @@ class TestProc < Test::Unit::TestCase assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters) assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters) + assert_equal([[:keyrest]], method(:pmk1).to_proc.parameters) + assert_equal([[:keyrest, :o]], method(:pmk2).to_proc.parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).to_proc.parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).to_proc.parameters) assert_equal([], "".method(:upcase).to_proc.parameters) assert_equal([[:rest]], "".method(:gsub).to_proc.parameters) @@ -1209,7 +1241,7 @@ class TestProc < Test::Unit::TestCase end def get_binding if: 1, case: 2, when: 3, begin: 4, end: 5 - a = 0 + a ||= 0 binding end |