mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
merge revision(s) 44630,44631: [Backport #9403]
* lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [ruby-core:58572] [Bug #9155] which start and end with '__'. [ruby-core:59718] [Bug #9403] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
484a6ffb78
commit
3da0a0cead
4 changed files with 66 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue