diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-04 03:47:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-04 03:47:57 +0000 |
commit | fc4de12302ab0e83e2bd0c76b9c3d4e7b3cbfee8 (patch) | |
tree | af898bfc7165050718b2c799de00121c4ccff4b2 /test | |
parent | b7c6db94ae2b9532640609163099c738decb31e6 (diff) |
delegate.rb: ignore unset target
* lib/delegate.rb (Delegator#method_missing): ignore the target if not
set, and delegate to global methods. [ruby-core:58572] [Bug #9155]
* lib/delegate.rb (Delegator#respond_to_missing): ditto.
* lib/delegate.rb (SimpleDelegator#__getobj__): yield and return if
not delegated but a block is given, like as Hash#fetch.
* lib/delegate.rb (DelegateClass#__getobj__): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_delegate.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb index 58fefea608..ca65ef3daa 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -168,4 +168,16 @@ class TestDelegateClass < Test::Unit::TestCase d.__getobj__ } end + + class Bug9155 < DelegateClass(Integer) + def initialize(value) + super(Integer(value)) + end + end + + def test_global_method_if_no_target + bug9155 = '[ruby-core:58572] [Bug #9155]' + x = assert_nothing_raised(ArgumentError, bug9155) {break Bug9155.new(1)} + assert_equal(1, x.to_i, bug9155) + end end |