diff options
Diffstat (limited to 'spec/ruby/language/proc_spec.rb')
| -rw-r--r-- | spec/ruby/language/proc_spec.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/spec/ruby/language/proc_spec.rb b/spec/ruby/language/proc_spec.rb index f8a29962b0..ca9a13aa61 100644 --- a/spec/ruby/language/proc_spec.rb +++ b/spec/ruby/language/proc_spec.rb @@ -104,7 +104,7 @@ describe "A Proc" do end it "assigns all passed values after the first to the rest argument" do - @l.call(1, 2, 3).should == [1, [2, 3]] + @l.call(1, 2, 3).should == [1, [2, 3]] end it "does not call #to_ary to convert a single passed object to an Array" do @@ -161,6 +161,18 @@ describe "A Proc" do end end + describe "taking |*a, b| arguments" do + it "assigns [] to the argument when passed no values" do + proc { |*a, b| [a, b] }.call.should == [[], nil] + end + end + + describe "taking |a, *b, c| arguments" do + it "assigns [] to the argument when passed no values" do + proc { |a, *b, c| [a, b, c] }.call.should == [nil, [], nil] + end + end + describe "taking |a, | arguments" do before :each do @l = lambda { |a, | a } @@ -223,18 +235,8 @@ describe "A Proc" do @p = proc { |*a, **kw| [a, kw] } end - ruby_version_is ""..."3.0" do - it 'autosplats keyword arguments and warns' do - -> { - @p.call([1, {a: 1}]).should == [[1], {a: 1}] - }.should complain(/warning: Using the last argument as keyword parameters is deprecated; maybe \*\* should be added to the call/) - end - end - - ruby_version_is "3.0" do - it 'does not autosplat keyword arguments' do - @p.call([1, {a: 1}]).should == [[[1, {a: 1}]], {}] - end + it 'does not autosplat keyword arguments' do + @p.call([1, {a: 1}]).should == [[[1, {a: 1}]], {}] end end |
