summaryrefslogtreecommitdiff
path: root/test/test_delegate.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-06 13:07:12 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-06 13:07:12 +0000
commite1797bc7dd2178550cf15d7a6af4f7f0eae003b4 (patch)
tree577490c191adc749c2b2b4ec9fc56e5b704bae7d /test/test_delegate.rb
parent1c544fccd27d399a444353905c8d921b1d1c5186 (diff)
* lib/delegate.rb (Delegator::public_api): take snapshot of
public method at the beginning time. * lib/delegate.rb (SimpleDelegator#initialize): use Delegator.public_api since public_method might be added after initialization. [ruby-dev:39383] * lib/delegate.rb (DelegateClass): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_delegate.rb')
-rw-r--r--test/test_delegate.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb
index 0b4c117..aecabe1 100644
--- a/test/test_delegate.rb
+++ b/test/test_delegate.rb
@@ -29,4 +29,26 @@ class TestDelegateClass < Test::Unit::TestCase
simple=SimpleDelegator.new([])
assert_equal(SimpleDelegator,simple.class)
end
+
+ class Object
+ def m
+ :o
+ end
+ end
+
+ class Foo
+ def m
+ :m
+ end
+ end
+
+ class Bar < DelegateClass(Foo)
+ end
+
+ def test_override
+ assert_equal(:o, Object.new.m)
+ assert_equal(:m, Foo.new.m)
+ assert_equal(:m, SimpleDelegator.new(Foo.new).m)
+ assert_equal(:m, Bar.new(Foo.new).m)
+ end
end