Skip to content

Commit

Permalink
Add specs for proc taking |*a, **kw| arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroProtagonist committed Oct 17, 2021
1 parent 1a3e832 commit b2d8310
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions language/proc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,30 @@
lambda { @l.call(obj) }.should raise_error(TypeError)
end
end

describe "taking |*a, **kw| arguments" do
before :each do
@p = proc { |*a, **kw| [a, kw] }
end

ruby_version_is ""..."2.7" do
it 'autosplats keyword arguments' do
@p.call([1, {a: 1}]).should == [[1], {a: 1}]
end
end

ruby_version_is "2.7"..."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' do
@p.call([1, {a: 1}]).should == [[[1, {a: 1}]], {}]
end
end
end
end

0 comments on commit b2d8310

Please sign in to comment.