summaryrefslogtreecommitdiff
path: root/test/test_delegate.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-25 00:04:14 -0700
committerJeremy Evans <code@jeremyevans.net>2019-10-10 13:15:00 -0700
commit2322c94dd65c0247b103e2f91411e37458e1466d (patch)
tree80e3bcebe14c0505590ecfff5bc4e622a7e087eb /test/test_delegate.rb
parent41719096957aa3d80e2e23d04ae288d2dee5328e (diff)
Support delegates for BasicObject
For BasicObject, bind the Kernel respond_to? instance method to the object and call it instead of calling the method directly. Also, use bind_call(recv, ...) for better performance. Fixes [Bug #16127]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2546
Diffstat (limited to 'test/test_delegate.rb')
-rw-r--r--test/test_delegate.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb
index 9634681..7f6e7c1 100644
--- a/test/test_delegate.rb
+++ b/test/test_delegate.rb
@@ -322,4 +322,12 @@ class TestDelegateClass < Test::Unit::TestCase
delegate.constants
end
end
+
+ def test_basicobject
+ o = BasicObject.new
+ def o.bar; 1; end
+ delegate = SimpleDelegator.new(o)
+ assert_equal(1, delegate.bar)
+ assert_raise(NoMethodError, /undefined method `foo' for/) { delegate.foo }
+ end
end