summaryrefslogtreecommitdiff
path: root/spec/ruby/core/unboundmethod
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2023-05-29 15:27:57 +0200
committerBenoit Daloze <eregontp@gmail.com>2023-05-29 15:27:57 +0200
commitc48d496e8cfdf8243d2beb28623954003adaf7fc (patch)
tree2d53327b3126360ccb42f9dae9889b7f329ad035 /spec/ruby/core/unboundmethod
parent98f500d0958d12b1909f4638abf33682d75f3fe6 (diff)
Update to ruby/spec@c3677cf
Diffstat (limited to 'spec/ruby/core/unboundmethod')
-rw-r--r--spec/ruby/core/unboundmethod/private_spec.rb11
-rw-r--r--spec/ruby/core/unboundmethod/protected_spec.rb11
-rw-r--r--spec/ruby/core/unboundmethod/public_spec.rb11
-rw-r--r--spec/ruby/core/unboundmethod/source_location_spec.rb7
4 files changed, 34 insertions, 6 deletions
diff --git a/spec/ruby/core/unboundmethod/private_spec.rb b/spec/ruby/core/unboundmethod/private_spec.rb
index fa735846bb..8ea50bb5d4 100644
--- a/spec/ruby/core/unboundmethod/private_spec.rb
+++ b/spec/ruby/core/unboundmethod/private_spec.rb
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "3.1"..."3.2" do
- describe "UnboundMethod#private?" do
+describe "UnboundMethod#private?" do
+ ruby_version_is "3.1"..."3.2" do
it "returns false when the method is public" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.private?.should == false
@@ -18,4 +18,11 @@ ruby_version_is "3.1"..."3.2" do
obj.method(:my_private_method).unbind.private?.should == true
end
end
+
+ ruby_version_is "3.2" do
+ it "has been removed" do
+ obj = UnboundMethodSpecs::Methods.new
+ obj.method(:my_private_method).unbind.should_not.respond_to?(:private?)
+ end
+ end
end
diff --git a/spec/ruby/core/unboundmethod/protected_spec.rb b/spec/ruby/core/unboundmethod/protected_spec.rb
index db00e7ef43..0c215d8638 100644
--- a/spec/ruby/core/unboundmethod/protected_spec.rb
+++ b/spec/ruby/core/unboundmethod/protected_spec.rb
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "3.1"..."3.2" do
- describe "UnboundMethod#protected?" do
+describe "UnboundMethod#protected?" do
+ ruby_version_is "3.1"..."3.2" do
it "returns false when the method is public" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.protected?.should == false
@@ -18,4 +18,11 @@ ruby_version_is "3.1"..."3.2" do
obj.method(:my_private_method).unbind.protected?.should == false
end
end
+
+ ruby_version_is "3.2" do
+ it "has been removed" do
+ obj = UnboundMethodSpecs::Methods.new
+ obj.method(:my_protected_method).unbind.should_not.respond_to?(:protected?)
+ end
+ end
end
diff --git a/spec/ruby/core/unboundmethod/public_spec.rb b/spec/ruby/core/unboundmethod/public_spec.rb
index 7b87a03b15..552bbf6eab 100644
--- a/spec/ruby/core/unboundmethod/public_spec.rb
+++ b/spec/ruby/core/unboundmethod/public_spec.rb
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "3.1"..."3.2" do
- describe "UnboundMethod#public?" do
+describe "UnboundMethod#public?" do
+ ruby_version_is "3.1"..."3.2" do
it "returns true when the method is public" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.public?.should == true
@@ -18,4 +18,11 @@ ruby_version_is "3.1"..."3.2" do
obj.method(:my_private_method).unbind.public?.should == false
end
end
+
+ ruby_version_is "3.2" do
+ it "has been removed" do
+ obj = UnboundMethodSpecs::Methods.new
+ obj.method(:my_public_method).unbind.should_not.respond_to?(:public?)
+ end
+ end
end
diff --git a/spec/ruby/core/unboundmethod/source_location_spec.rb b/spec/ruby/core/unboundmethod/source_location_spec.rb
index 96933a5d40..c6823aa84b 100644
--- a/spec/ruby/core/unboundmethod/source_location_spec.rb
+++ b/spec/ruby/core/unboundmethod/source_location_spec.rb
@@ -49,4 +49,11 @@ describe "UnboundMethod#source_location" do
method.source_location[0].should =~ /#{__FILE__}/
method.source_location[1].should == line
end
+
+ it "works for eval with a given line" do
+ c = Class.new do
+ eval('def m; end', nil, "foo", 100)
+ end
+ c.instance_method(:m).source_location.should == ["foo", 100]
+ end
end