summaryrefslogtreecommitdiff
path: root/spec/ruby/core/method
diff options
context:
space:
mode:
authorKoichi Sasada <[email protected]>2022-12-03 05:55:33 +0900
committerKoichi Sasada <[email protected]>2022-12-03 08:53:12 +0900
commit59e389af2893c0fcf8b2cfa008c9a16825bf56ff (patch)
tree31224e3498843912e2fc8734710e03224aaca21c /spec/ruby/core/method
parent7161bf34e161979b97dbc0c1f7450c195faffcfe (diff)
UnboundMethod only refer defined_class
UnboundMethod records caller's class, like `D` or `E` on the following case: ```ruby class C def foo = :foo end class D < C end class E < C end d = D.instance_method(:foo) e = E.instance_method(:foo) ``` But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't record `D` or `E`. This behavior changes the following methods: * `UnboundMethod#inspect` (doesn't show caller's class) * `UnboundMethod#==` (`d == e` for example) fix https://bugs.ruby-lang.org/issues/18798
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6855
Diffstat (limited to 'spec/ruby/core/method')
-rw-r--r--spec/ruby/core/method/unbind_spec.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/ruby/core/method/unbind_spec.rb b/spec/ruby/core/method/unbind_spec.rb
index cdd3a808f2..bdedd513ce 100644
--- a/spec/ruby/core/method/unbind_spec.rb
+++ b/spec/ruby/core/method/unbind_spec.rb
@@ -27,8 +27,16 @@ describe "Method#unbind" do
@string.should =~ /MethodSpecs::MyMod/
end
- it "returns a String containing the Module the method is referenced from" do
- @string.should =~ /MethodSpecs::MySub/
+ ruby_version_is ""..."3.2" do
+ it "returns a String containing the Module the method is referenced from" do
+ @string.should =~ /MethodSpecs::MySub/
+ end
+ end
+
+ ruby_version_is "3.2" do
+ it "returns a String containing the Module the method is referenced from" do
+ @string.should =~ /MethodSpecs::MyMod/
+ end
end
end