diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-24 03:35:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-24 03:35:29 +0000 |
commit | 3c45a7899e239e7ece3c778d9f71e3be85fdfbed (patch) | |
tree | 6fef657de1a1751f08f92877a6d3fb469835c0c7 /test/test_delegate.rb | |
parent | dc62793a910097b2bb6a48ce5b6669c3ddb934ed (diff) |
Delegate to `eql?` [Fix GH-1564]
* lib/delegate.rb (eql?): Delegate to `eql?` of the inner object.
based on the patch by giginet <[email protected]>.
[ruby-core:76950] [Bug #12684]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_delegate.rb')
-rw-r--r-- | test/test_delegate.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb index 18c175c719..48bf9cdbf0 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -3,6 +3,14 @@ require 'test/unit' require 'delegate' class TestDelegateClass < Test::Unit::TestCase + module PP + def mu_pp(obj) + str = super + str = "#<#{obj.class}: #{str}>" if Delegator === obj + str + end + end + module M attr_reader :m end @@ -119,6 +127,18 @@ class TestDelegateClass < Test::Unit::TestCase assert_equal([:bar], s.methods(false)) end + def test_eql? + extend PP + s0 = SimpleDelegator.new("foo") + s1 = SimpleDelegator.new("bar") + s2 = SimpleDelegator.new("foo") + assert_operator(s0, :eql?, s0) + assert_operator(s0, :eql?, "foo") + assert_operator(s0, :eql?, s2) + assert_not_operator(s0, :eql?, s1) + assert_not_operator(s0, :eql?, "bar") + end + class Foo private def delegate_test_private |