Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs for proc taking |*a, **kw| arguments [Feature #16166] #882

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 arguments' do
@p.call([1, {a: 1}]).should == [[[1, {a: 1}]], {}]
end
end
end
end