diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-17 11:05:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-17 11:05:03 +0000 |
commit | bcaec55695c0592b911d361750834ef0c1a7842f (patch) | |
tree | 7beaf2416731148c72e6e6578938eafb9514aca9 /test | |
parent | 191b373d26a48058bcc8955bf3afe426f60eaaea (diff) | |
download | ruby-bcaec55695c0592b911d361750834ef0c1a7842f.tar.gz |
delegate.rb: keep special methods
* lib/delegate.rb (Delegator): keep source information methods
which start and end with '__'. [ruby-core:58572] [Bug #9155]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_delegate.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb index ca65ef3daa..6270cc61b6 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -180,4 +180,61 @@ class TestDelegateClass < Test::Unit::TestCase x = assert_nothing_raised(ArgumentError, bug9155) {break Bug9155.new(1)} assert_equal(1, x.to_i, bug9155) end + + class Bug9403 + Name = '[ruby-core:59718] [Bug #9403]' + SD = SimpleDelegator.new(new) + class << SD + def method_name + __method__ + end + def callee_name + __callee__ + end + alias aliased_name callee_name + def dir_name + __dir__ + end + end + dc = DelegateClass(self) + dc.class_eval do + def method_name + __method__ + end + def callee_name + __callee__ + end + alias aliased_name callee_name + def dir_name + __dir__ + end + end + DC = dc.new(new) + end + + def test_method_in_simple_delegator + assert_equal(:method_name, Bug9403::SD.method_name, Bug9403::Name) + end + + def test_callee_in_simple_delegator + assert_equal(:callee_name, Bug9403::SD.callee_name, Bug9403::Name) + assert_equal(:aliased_name, Bug9403::SD.aliased_name, Bug9403::Name) + end + + def test_dir_in_simple_delegator + assert_equal(__dir__, Bug9403::SD.dir_name, Bug9403::Name) + end + + def test_method_in_delegator_class + assert_equal(:method_name, Bug9403::DC.method_name, Bug9403::Name) + end + + def test_callee_in_delegator_class + assert_equal(:callee_name, Bug9403::DC.callee_name, Bug9403::Name) + assert_equal(:aliased_name, Bug9403::DC.aliased_name, Bug9403::Name) + end + + def test_dir_in_delegator_class + assert_equal(__dir__, Bug9403::DC.dir_name, Bug9403::Name) + end end |