aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-26 16:05:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-26 16:05:30 +0000
commit298349d03bcdb6c25420d9a92265816d59892a1f (patch)
treeefd250ee3f71d001f05d1d2ecb072cd05473f2c4 /test
parent3fbc65d47fe8d446dde8fe77d3b76fb81f8ffba1 (diff)
downloadruby-298349d03bcdb6c25420d9a92265816d59892a1f.tar.gz
* vm_method.c (obj_respond_to): fix the respond_to_missing? override
case. based on the patch by Jeremy Evans at [ruby-core:38417]. [Feature #5072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_object.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 2935885431..c4f0f79db3 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -334,6 +334,19 @@ class TestObject < Test::Unit::TestCase
assert_nothing_raised(bug2494) {[b].flatten}
end
+ def test_respond_to_missing_string
+ c = Class.new do
+ def respond_to_missing?(id, priv)
+ !(id !~ /\Agadzoks\d+\z/) ^ priv
+ end
+ end
+ foo = c.new
+ assert_equal(false, foo.respond_to?("gadzooks16"))
+ assert_equal(true, foo.respond_to?("gadzooks17", true))
+ assert_equal(true, foo.respond_to?("gadzoks16"))
+ assert_equal(false, foo.respond_to?("gadzoks17", true))
+ end
+
def test_respond_to_missing
c = Class.new do
def respond_to_missing?(id, priv)