summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-30 12:44:47 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-30 12:44:47 +0000
commit3e23ba599d8c7787195333a5605de56df4c21b96 (patch)
treeec9fe51c0ce3009469fc9137d9642cfe9e3e07b8 /test
parentc8f9b4d5468e49962b94b245397f549eb9101e51 (diff)
merges r25245 from trunk into ruby_1_9_1.
and fixes a mistake in the test case. -- * 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/branches/ruby_1_9_1@26474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_delegate.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb
index 5fa60dee81..9dc122ba03 100644
--- a/test/test_delegate.rb
+++ b/test/test_delegate.rb
@@ -30,4 +30,23 @@ class TestDelegateClass < Test::Unit::TestCase
simple=SimpleDelegator.new([])
assert_equal(SimpleDelegator,simple.class)
end
+
+ class Foo
+ def m
+ :m
+ end
+ end
+
+ class Bar < DelegateClass(Foo)
+ end
+
+ def test_override
+ ::Object.class_eval{ def m; :o end }
+ 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)
+ ensure
+ ::Object.class_eval{ remove_method :m }
+ end
end