summaryrefslogtreecommitdiff
path: root/test/test_delegate.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-21 09:47:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-21 09:47:31 +0000
commitbb6607404a993c98d1ede9560b0f34c7551bf0f5 (patch)
tree4c46b4b6bd8d70e94d1da7b00c5659f2edf0558d /test/test_delegate.rb
parent2958ecae6793ad265bd312c225f0c7a6fa919522 (diff)
delegate.rb: check if target is set
* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set. * lib/delegate.rb (DelegateClass#__getobj__): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_delegate.rb')
-rw-r--r--test/test_delegate.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb
index 6448ef90dd..58fefea608 100644
--- a/test/test_delegate.rb
+++ b/test/test_delegate.rb
@@ -154,4 +154,18 @@ class TestDelegateClass < Test::Unit::TestCase
end.new(Object.new)
assert_equal("foo", d.send(:foo))
end
+
+ def test_unset_simple_delegator
+ d = SimpleDelegator.allocate
+ assert_raise_with_message(ArgumentError, /not delegated/) {
+ d.__getobj__
+ }
+ end
+
+ def test_unset_delegate_class
+ d = IV.allocate
+ assert_raise_with_message(ArgumentError, /not delegated/) {
+ d.__getobj__
+ }
+ end
end