Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions spec/ruby/core/unboundmethod/equal_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@

@method_one = UnboundMethodSpecs::Methods.instance_method(:one)
@method_two = UnboundMethodSpecs::Methods.instance_method(:two)

@mixin = UnboundMethodSpecs::Mixin.instance_method(:mixin_method)
@includer_base = UnboundMethodSpecs::IncluderBase.new.method(:mixin_method).unbind
@includer_child = UnboundMethodSpecs::IncluderChild.new.method(:mixin_method).unbind
@extender_base = UnboundMethodSpecs::ExtenderBase.method(:mixin_method).unbind
@extender_child = UnboundMethodSpecs::ExtenderChild.method(:mixin_method).unbind
end

it "returns true if objects refer to the same method" do
Expand Down Expand Up @@ -91,6 +97,30 @@
(@includer == @includee).should == true
end

ruby_bug "#21873", ""..."4.1" do
it "returns true if same method is present in an object through module inclusion" do
(@mixin == @includer_base).should == true
(@includer_base == @mixin).should == true

(@mixin == @includer_child).should == true
(@includer_child == @mixin).should == true

(@includer_base == @includer_child).should == true
(@includer_child == @includer_base).should == true
end

it "returns true if same method is present in an object through module extension" do
(@mixin == @extender_base).should == true
(@extender_base == @mixin).should == true

(@mixin == @extender_child).should == true
(@extender_child == @mixin).should == true

(@extender_base == @extender_child).should == true
(@extender_child == @extender_base).should == true
end
end

it "returns false if both have same Module, same name, identical body but not the same" do
class UnboundMethodSpecs::Methods
def discard_1; :discard; end
Expand Down
16 changes: 16 additions & 0 deletions spec/ruby/core/unboundmethod/fixtures/classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ class << self
end
end

module Mixin
def mixin_method; end
end

class IncluderBase
include Mixin
end

class IncluderChild < IncluderBase; end

class ExtenderBase
extend Mixin
end

class ExtenderChild < ExtenderBase; end

class A
def baz(a, b)
return [__FILE__, self.class]
Expand Down
Loading