mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Proc from Symbol needs a receiver
So its arity should be -2 instead of -1. [Bug #16640] https://bugs.ruby-lang.org/issues/16640#change-84337
This commit is contained in:
parent
31748e69c8
commit
5b29ea0845
4 changed files with 19 additions and 8 deletions
|
@ -12,18 +12,20 @@ describe "Symbol#to_proc" do
|
|||
:to_s.to_proc.call(obj).should == "Received #to_s"
|
||||
end
|
||||
|
||||
it "produces a proc with arity -1" do
|
||||
expected_arity = ruby_version_is("2.8") {-2} || -1
|
||||
it "produces a proc with arity #{expected_arity}" do
|
||||
pr = :to_s.to_proc
|
||||
pr.arity.should == -1
|
||||
pr.arity.should == expected_arity
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when calling #call on the Proc without receiver" do
|
||||
-> { :object_id.to_proc.call }.should raise_error(ArgumentError, "no receiver given")
|
||||
end
|
||||
|
||||
it "produces a proc that always returns [[:rest]] for #parameters" do
|
||||
expected_parameters = ruby_version_is("2.8") {[[:req], [:rest]]} || [[:rest]]
|
||||
it "produces a proc that always returns #{expected_parameters} for #parameters" do
|
||||
pr = :to_s.to_proc
|
||||
pr.parameters.should == [[:rest]]
|
||||
pr.parameters.should == expected_parameters
|
||||
end
|
||||
|
||||
it "passes along the block passed to Proc#call" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue