mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
delegate.rb: get rid of global function interference
* lib/delegate.rb (Delegator#send): override to get rid of global function interference. [Fixes GH-449] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3eac78dd88
commit
ca5739979d
3 changed files with 18 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Nov 15 17:07:31 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/delegate.rb (Delegator#send): override to get rid of global function interference.
|
||||
[Fixes GH-449]
|
||||
|
||||
Fri Nov 15 01:06:04 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/objspace/objspace_dump.c (dump_output): allow IO object as
|
||||
|
|
|
@ -74,6 +74,7 @@ class Delegator < BasicObject
|
|||
$@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:"o =~ t} if $@
|
||||
end
|
||||
end
|
||||
alias send method_missing
|
||||
|
||||
#
|
||||
# Checks for a method provided by this the delegate object by forwarding the
|
||||
|
|
|
@ -133,4 +133,16 @@ class TestDelegateClass < Test::Unit::TestCase
|
|||
assert_raise(NoMethodError, '[ruby-dev:40314]#4') {d.delegate_test_private}
|
||||
assert_raise(NoMethodError, '[ruby-dev:40314]#5') {d.send(:delegate_test_private)}
|
||||
end
|
||||
|
||||
def test_global_function
|
||||
klass = Class.new do
|
||||
def open
|
||||
end
|
||||
end
|
||||
obj = klass.new
|
||||
d = SimpleDelegator.new(obj)
|
||||
assert_nothing_raised(ArgumentError) {obj.open}
|
||||
assert_nothing_raised(ArgumentError) {d.open}
|
||||
assert_nothing_raised(ArgumentError) {d.send(:open)}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue