diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-22 10:40:25 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-22 10:49:59 +0900 |
commit | 5b29ea0845c14092abd866ce0183c52635bade4c (patch) | |
tree | 1c01654c72d24c7fa499bb5b6f91fc3e55d6c84a /spec | |
parent | 31748e69c84894ac8f042a67d1320db8593c9ce1 (diff) | |
download | ruby-5b29ea0845c14092abd866ce0183c52635bade4c.tar.gz |
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
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ruby/core/symbol/to_proc_spec.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/spec/ruby/core/symbol/to_proc_spec.rb b/spec/ruby/core/symbol/to_proc_spec.rb index a58187de2e..27eb6970c4 100644 --- a/spec/ruby/core/symbol/to_proc_spec.rb +++ b/spec/ruby/core/symbol/to_proc_spec.rb @@ -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 |