diff options
author | Benoit Daloze <[email protected]> | 2023-02-27 21:02:44 +0100 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2023-02-27 21:02:44 +0100 |
commit | 18b4def471bb901d0baa4a1307185484cb05815f (patch) | |
tree | 779b24566144e9ee06c6f8de35bd2f7fd74ccdb4 /spec/ruby/core/unboundmethod | |
parent | de60139053fa7c561858c5c5556d61c82f361dd9 (diff) |
Update to ruby/spec@e7dc804
Diffstat (limited to 'spec/ruby/core/unboundmethod')
-rw-r--r-- | spec/ruby/core/unboundmethod/bind_call_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/unboundmethod/bind_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/unboundmethod/fixtures/classes.rb | 4 |
3 files changed, 20 insertions, 0 deletions
diff --git a/spec/ruby/core/unboundmethod/bind_call_spec.rb b/spec/ruby/core/unboundmethod/bind_call_spec.rb index 8f25f8bd0d..80b2095d86 100644 --- a/spec/ruby/core/unboundmethod/bind_call_spec.rb +++ b/spec/ruby/core/unboundmethod/bind_call_spec.rb @@ -7,6 +7,8 @@ describe "UnboundMethod#bind_call" do @parent_um = UnboundMethodSpecs::Parent.new.method(:foo).unbind @child1_um = UnboundMethodSpecs::Child1.new.method(:foo).unbind @child2_um = UnboundMethodSpecs::Child2.new.method(:foo).unbind + @normal_um_super = UnboundMethodSpecs::Mod.instance_method(:foo_super) + @parent_um_super = UnboundMethodSpecs::Parent.new.method(:foo_super).unbind end it "raises TypeError if object is not kind_of? the Module the method defined in" do @@ -47,4 +49,10 @@ describe "UnboundMethod#bind_call" do um = p.method(:singleton_method).unbind ->{ um.bind_call(other) }.should raise_error(TypeError) end + + it "allows calling super for module methods bound to hierarchies that do not already have that module" do + p = UnboundMethodSpecs::Parent.new + + @normal_um_super.bind_call(p).should == true + end end diff --git a/spec/ruby/core/unboundmethod/bind_spec.rb b/spec/ruby/core/unboundmethod/bind_spec.rb index 03aaa22e74..7658b664e5 100644 --- a/spec/ruby/core/unboundmethod/bind_spec.rb +++ b/spec/ruby/core/unboundmethod/bind_spec.rb @@ -7,6 +7,8 @@ describe "UnboundMethod#bind" do @parent_um = UnboundMethodSpecs::Parent.new.method(:foo).unbind @child1_um = UnboundMethodSpecs::Child1.new.method(:foo).unbind @child2_um = UnboundMethodSpecs::Child2.new.method(:foo).unbind + @normal_um_super = UnboundMethodSpecs::Mod.instance_method(:foo_super) + @parent_um_super = UnboundMethodSpecs::Parent.new.method(:foo_super).unbind end it "raises TypeError if object is not kind_of? the Module the method defined in" do @@ -58,4 +60,10 @@ describe "UnboundMethod#bind" do um = p.method(:singleton_method).unbind ->{ um.bind(other) }.should raise_error(TypeError) end + + it "allows calling super for module methods bound to hierarchies that do not already have that module" do + p = UnboundMethodSpecs::Parent.new + + @normal_um_super.bind(p).call.should == true + end end diff --git a/spec/ruby/core/unboundmethod/fixtures/classes.rb b/spec/ruby/core/unboundmethod/fixtures/classes.rb index 6ab958d447..28d8e0a965 100644 --- a/spec/ruby/core/unboundmethod/fixtures/classes.rb +++ b/spec/ruby/core/unboundmethod/fixtures/classes.rb @@ -22,6 +22,7 @@ module UnboundMethodSpecs module Mod def from_mod; end + def foo_super; super; end end class Methods @@ -63,6 +64,9 @@ module UnboundMethodSpecs class Parent def foo; end + def foo_super + true + end def self.class_method "I am #{name}" end |